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

How to use
installModules
method
in
toothpick.ScopeImpl

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

origin: stephanenicolas/toothpick

@Override
public void installModules(Module... modules) {
 installModules(false, modules);
}
origin: stephanenicolas/toothpick

@Override
public synchronized void installTestModules(Module... modules) {
 if (hasTestModules) {
  throw new IllegalStateException("TestModules can only be installed once per scope.");
 }
 installModules(true, modules);
 hasTestModules = true;
}
origin: stephanenicolas/toothpick

@Test(expected = IllegalStateException.class)
public void installModules_shouldFailWhenModuleHasIssues() {
 //GIVEN
 ScopeImpl scope = new ScopeImpl("");
 //WHEN
 scope.installModules(new BuggyModule());
 //THEN
 fail();
}
origin: stephanenicolas/toothpick

@Test(expected = IllegalStateException.class)
public void installModules_shouldThrowAnException_whenModuleHasANullBinding() {
 //GIVEN
 ScopeImpl scope = new ScopeImpl("");
 //WHEN
 scope.installModules(new NullBindingModule());
 //THEN
 fail("Should throw an exception.");
}
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 void installModules(Module... modules) {
 installModules(false, modules);
}
origin: com.github.stephanenicolas.toothpick/toothpick-runtime

@Override
public synchronized void installTestModules(Module... modules) {
 if (hasTestModules) {
  throw new IllegalStateException("TestModules can only be installed once per scope.");
 }
 installModules(true, modules);
 hasTestModules = true;
}
origin: com.github.stephanenicolas/toothpick-runtime

@Override
public synchronized void installTestModules(Module... modules) {
 if (hasTestModules) {
  throw new IllegalStateException("TestModules can only be installed once per scope.");
 }
 hasTestModules = false;
 installModules(modules);
 hasTestModules = true;
}
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 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 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));
}
toothpickScopeImplinstallModules

Popular methods of ScopeImpl

  • <init>
  • 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
  • getInstance
  • 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

  • Making http post requests using okhttp
  • getResourceAsStream (ClassLoader)
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JLabel (javax.swing)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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