Search in sources :

Example 11 with Dependency

use of com.google.gwt.inject.rebind.binding.Dependency in project google-gin by gwtplus.

the class PathFinderTest method testRequiredPath_OptionalInUnresolved.

public void testRequiredPath_OptionalInUnresolved() throws Exception {
    DependencyGraph graph = new DependencyGraph.Builder(origin).addEdge(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)).addEdge(new Dependency(Dependency.GINJECTOR, baz(), true, false, SOURCE)).addEdge(new Dependency(foo(), bar(), SOURCE)).addEdge(new Dependency(bar(), baz(), SOURCE)).build();
    control.replay();
    assertEquals(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE), new Dependency(foo(), bar(), SOURCE), new Dependency(bar(), baz(), SOURCE)), new PathFinder().onGraph(graph).addRoots(Dependency.GINJECTOR).addDestinations(baz()).withOnlyRequiredEdges(true).findShortestPath());
    control.verify();
}
Also used : Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 12 with Dependency

use of com.google.gwt.inject.rebind.binding.Dependency in project google-gin by gwtplus.

the class PathFinderTest method testFindShortestPath_MultipleDestinations.

public void testFindShortestPath_MultipleDestinations() throws Exception {
    DependencyGraph graph = new DependencyGraph.Builder(origin).addEdge(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)).addEdge(new Dependency(foo(), bar(), SOURCE)).addEdge(new Dependency(bar(), baz(), SOURCE)).build();
    control.replay();
    assertEquals(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE), new Dependency(foo(), bar(), SOURCE)), new PathFinder().onGraph(graph).addRoots(Dependency.GINJECTOR).addDestinations(baz(), bar()).findShortestPath());
    control.verify();
}
Also used : Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 13 with Dependency

use of com.google.gwt.inject.rebind.binding.Dependency in project google-gin by gwtplus.

the class RequiredKeySetTest method testRequiredNotHiddenByOptional.

public void testRequiredNotHiddenByOptional() throws Exception {
    EasyMock.expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
    control.replay();
    DependencyGraph graph = new DependencyGraph.Builder(origin).addEdge(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)).addEdge(new Dependency(foo(), bar(), true, false, SOURCE)).addEdge(new Dependency(baz(), bar(), SOURCE)).addEdge(new Dependency(foo(), baz(), SOURCE)).build();
    RequiredKeySet requiredKeys = new RequiredKeySet(graph);
    assertTrue(requiredKeys.isRequired(foo()));
    assertTrue(requiredKeys.isRequired(bar()));
    assertTrue(requiredKeys.isRequired(baz()));
    control.verify();
}
Also used : Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 14 with Dependency

use of com.google.gwt.inject.rebind.binding.Dependency in project google-gin by gwtplus.

the class RequiredKeySetTest method testChainOfSingleDeps.

public void testChainOfSingleDeps() throws Exception {
    EasyMock.expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
    control.replay();
    DependencyGraph graph = new DependencyGraph.Builder(origin).addEdge(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)).addEdge(new Dependency(foo(), bar(), SOURCE)).addEdge(new Dependency(bar(), baz(), SOURCE)).build();
    RequiredKeySet requiredKeys = new RequiredKeySet(graph);
    assertTrue(requiredKeys.isRequired(foo()));
    assertTrue(requiredKeys.isRequired(bar()));
    assertTrue(requiredKeys.isRequired(baz()));
    control.verify();
}
Also used : Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 15 with Dependency

use of com.google.gwt.inject.rebind.binding.Dependency in project google-gin by gwtplus.

the class BindingInstallerTest method testInstallImplicitBindings.

public void testInstallImplicitBindings() throws Exception {
    // Tests that implicit bindings that are not already available in the origin are made accessible
    // foo and bar both had implicit bindings created (with no dependencies).  Foo is installed in
    // the child, and bar is installed in root.  We should add a binding to make bar accessible in
    // the child.
    expect(positions.getInstallPosition(foo())).andStubReturn(child);
    expect(positions.getInstallPosition(bar())).andStubReturn(root);
    Map<Key<?>, Binding> implicitBindingMap = new HashMap<Key<?>, Binding>();
    // Parent Binding to make bar available to child
    ParentBinding barBinding = control.createMock("barBinding", ParentBinding.class);
    expect(child.isBound(bar())).andReturn(false);
    expect(bindingFactory.getParentBinding(eq(bar()), eq(root), isA(Context.class))).andReturn(barBinding);
    // Implicit binding for Foo
    Binding fooBinding = control.createMock("fooBinding", Binding.class);
    expect(graph.getDependenciesOf(foo())).andReturn(TestUtils.dependencyList());
    implicitBindingMap.put(foo(), fooBinding);
    expect(output.getImplicitBindings()).andReturn(implicitBindingMap.entrySet());
    expect(child.getDependencies()).andReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE), new Dependency(Dependency.GINJECTOR, bar(), SOURCE)));
    child.addBinding(bar(), barBinding);
    child.addBinding(foo(), fooBinding);
    control.replay();
    installer.installBindings(output);
    control.verify();
}
Also used : Binding(com.google.gwt.inject.rebind.binding.Binding) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding) Context(com.google.gwt.inject.rebind.binding.Context) ParentBinding(com.google.gwt.inject.rebind.binding.ParentBinding) HashMap(java.util.HashMap) Dependency(com.google.gwt.inject.rebind.binding.Dependency) Key(com.google.inject.Key)

Aggregations

Dependency (com.google.gwt.inject.rebind.binding.Dependency)50 DependencyExplorerOutput (com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput)10 GinjectorBindings (com.google.gwt.inject.rebind.GinjectorBindings)8 Key (com.google.inject.Key)6 Binding (com.google.gwt.inject.rebind.binding.Binding)5 ParentBinding (com.google.gwt.inject.rebind.binding.ParentBinding)4 Method (java.lang.reflect.Method)4 LinkedHashSet (java.util.LinkedHashSet)4 ExposedChildBinding (com.google.gwt.inject.rebind.binding.ExposedChildBinding)3 HashMap (java.util.HashMap)3 Context (com.google.gwt.inject.rebind.binding.Context)2 BindingCreationException (com.google.gwt.inject.rebind.resolution.ImplicitBindingCreator.BindingCreationException)2 ArrayList (java.util.ArrayList)2 FieldLiteral (com.google.gwt.inject.rebind.reflect.FieldLiteral)1 InjectionPoint (com.google.inject.spi.InjectionPoint)1 Field (java.lang.reflect.Field)1 Member (java.lang.reflect.Member)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1