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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations