Tabnine Logo
ScopeImpl.getInstance
Code IndexAdd Tabnine to your IDE (free)

How to use
getInstance
method
in
toothpick.ScopeImpl

Best Java code snippets using toothpick.ScopeImpl.getInstance (Showing top 10 results out of 315)

origin: stephanenicolas/toothpick

@Override
public <T> T getInstance(Class<T> clazz) {
 return getInstance(clazz, null);
}
origin: stephanenicolas/toothpick

@Test(expected = IllegalStateException.class)
public void getInstance_shouldFail_whenScopeIsClosed() {
 //GIVEN
 ScopeImpl scope = new ScopeImpl("");
 //WHEN
 scope.close();
 scope.getInstance(Foo.class);
 //THEN
}
origin: stephanenicolas/toothpick

@Test
public void reset_shouldRebindScope() throws Exception {
 //GIVEN
 ScopeImpl scope = new ScopeImpl("root");
 //WHEN
 scope.reset();
 //THEN
 assertThat(scope.getInstance(Scope.class), notNullValue());
}
origin: stephanenicolas/toothpick

@Test
public void installOverrideModules_shouldNotOverrideOtherBindings() {
 //GIVEN
 Foo testFoo = new Foo();
 ScopeImpl scope = new ScopeImpl("");
 scope.installTestModules(new TestModule(testFoo));
 scope.installModules(new ProdModule2());
 //WHEN
 Foo fooInstance = scope.getInstance(Foo.class);
 Bar barInstance = scope.getInstance(Bar.class);
 //THEN
 assertThat(fooInstance, sameInstance(testFoo));
 assertThat(barInstance, notNullValue());
}
origin: stephanenicolas/toothpick

@Test
public void installOverrideModules_shouldNotInstallOverrideBindings_whenCalledWithoutTestModules() {
 //GIVEN
 ScopeImpl scope = new ScopeImpl("");
 scope.installTestModules();
 scope.installModules(new ProdModule());
 //WHEN
 Foo instance = scope.getInstance(Foo.class);
 //THEN
 assertThat(instance, notNullValue());
}
origin: com.github.stephanenicolas.toothpick/toothpick-runtime

@Override
public <T> T getInstance(Class<T> clazz) {
 return getInstance(clazz, null);
}
origin: stephanenicolas/toothpick

@Test(expected = NoFactoryFoundException.class)
public void reset_shouldResetBoundProviders_andFlagTheTestModuleToFalse() throws Exception {
 //GIVEN
 ScopeImpl scope = new ScopeImpl("root");
 scope.installTestModules(new Module() { {
  bind(IFoo.class).to(Foo.class);
 } });
 //WHEN
 scope.reset();
 //THEN
 scope.installTestModules(); // Should not crash
 scope.getInstance(IFoo.class); // Should crash as we don't have the binding for IFoo anymore
}
origin: stephanenicolas/toothpick

@Test
public void testToString() {
 //GIVEN
 ScopeImpl scope = new ScopeImpl("root");
 scope.installModules(new TestModule1());
 ScopeImpl childScope = new ScopeImpl("child");
 scope.addChild(childScope);
 //WHEN
 childScope.getInstance(Bar.class);
 String dump = scope.toString();
 //THEN
 Pattern expected = Pattern.compile("root:\\d+.*"
   + "Providers: \\[toothpick.Scope,toothpick.data.Foo\\].*"
   + "\\\\---child:\\d+.*"
   + "Providers:.*\\[toothpick.Scope\\].*"
   + "Unbound providers: \\[toothpick.data.Bar\\].*", Pattern.DOTALL);
 assertThat(dump, MatchesPattern.matchesPattern(expected));
}
origin: stephanenicolas/toothpick

@Test
public void installTestModules_shouldOverrideBindings_whenInstalledAfterProductionModules() {
 //GIVEN
 Foo testFoo = new Foo();
 ScopeImpl scope = new ScopeImpl("");
 scope.installModules(new ProdModule());
 scope.installTestModules(new TestModule(testFoo));
 //WHEN
 Foo instance = scope.getInstance(Foo.class);
 //THEN
 assertThat(instance, sameInstance(testFoo));
}
origin: stephanenicolas/toothpick

@Test
public void installOverrideModules_shouldInstallOverrideBindings_whenCalledOnce() {
 //GIVEN
 Foo testFoo = new Foo();
 ScopeImpl scope = new ScopeImpl("");
 scope.installTestModules(new TestModule(testFoo));
 scope.installModules(new ProdModule());
 //WHEN
 Foo instance = scope.getInstance(Foo.class);
 //THEN
 assertThat(instance, sameInstance(testFoo));
}
toothpickScopeImplgetInstance

Popular methods of ScopeImpl

  • <init>
  • installModules
  • lookupProvider
    The core of Toothpick internals : the provider lookup. It will look for a scoped provider, bubbling
  • toProvider
  • createInternalProvider
  • getBoundProvider
    Obtains the provider of the class clazz and name bindingName, if any. The returned provider will be
  • getInternalProvider
    Obtains the provider of the class clazz and name bindingName. The returned provider can either be bo
  • getLazy
  • getName
  • getProvider
  • getRootScope
  • getUnBoundProvider
    Obtains the provider of the class clazz and name bindingName, if any. The returned provider will bel
  • getRootScope,
  • getUnBoundProvider,
  • installBoundProvider,
  • installInternalProvider,
  • installModule,
  • installNamedProvider,
  • installScopedProvider,
  • installUnBoundProvider,
  • installUnNamedProvider

Popular in Java

  • Start an intent from android
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • requestLocationUpdates (LocationManager)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now