use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testEdgeInUnresolvedAndOptional.
public void testEdgeInUnresolvedAndOptional() throws Exception {
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(foo(), bar(), SOURCE)));
expect(origin.getParent()).andStubReturn(null);
expect(origin.isBound(foo())).andReturn(true).anyTimes();
expect(origin.isBound(bar())).andReturn(false).anyTimes();
expect(origin.isPinned(bar())).andReturn(false).anyTimes();
expect(origin.isBound(baz())).andReturn(true).anyTimes();
expect(bindingCreator.create(bar())).andReturn(binding);
expect(binding.getDependencies()).andReturn(TestUtils.dependencyList(new Dependency(bar(), baz(), true, false, SOURCE)));
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
DependencyGraph graph = output.getGraph();
assertContentsAnyOrder(graph.getDependenciesOf(foo()), new Dependency(foo(), bar(), SOURCE));
assertEmpty(graph.getDependenciesTargeting(foo()));
assertContentsAnyOrder(graph.getDependenciesOf(bar()), new Dependency(bar(), baz(), true, false, SOURCE));
assertContentsAnyOrder(graph.getDependenciesTargeting(bar()), new Dependency(foo(), bar(), SOURCE));
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testImplicitBinding.
public void testImplicitBinding() throws Exception {
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
expect(origin.getParent()).andStubReturn(null);
expect(origin.isBound(foo())).andReturn(false).anyTimes();
expect(origin.isPinned(foo())).andReturn(false).anyTimes();
expect(bindingCreator.create(foo())).andReturn(binding);
expect(binding.getDependencies()).andReturn(TestUtils.dependencyList(new Dependency(foo(), bar(), SOURCE)));
expect(origin.isBound(bar())).andReturn(true).anyTimes();
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertSame(origin, output.getPreExistingLocations().get(bar()));
assertEmpty(output.getBindingErrors());
assertEquals(1, output.getImplicitlyBoundKeys().size());
assertEquals(foo(), output.getImplicitBindings().iterator().next().getKey());
assertEquals(binding, output.getImplicitBindings().iterator().next().getValue());
DependencyGraph graph = output.getGraph();
assertContentsAnyOrder(graph.getDependenciesTargeting(foo()), new Dependency(Dependency.GINJECTOR, foo(), SOURCE));
assertContentsAnyOrder(graph.getDependenciesTargeting(bar()), new Dependency(foo(), bar(), SOURCE));
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testImplicitBindingFailed.
public void testImplicitBindingFailed() throws Exception {
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
expect(origin.getParent()).andStubReturn(null);
expect(origin.isBound(foo())).andReturn(false).anyTimes();
expect(origin.isPinned(foo())).andReturn(false).anyTimes();
expect(bindingCreator.create(foo())).andThrow(new BindingCreationException("failed"));
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertEquals(1, output.getBindingErrors().size());
assertEquals(foo(), output.getBindingErrors().iterator().next().getKey());
assertEquals("failed", output.getBindingErrors().iterator().next().getValue());
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testSourcePositioned.
/**
* Tests that when we have a dependency that installs multiple steps (eg, GINJECTOR -> foo -> bar)
* we will treat foo as previously positioned.
*/
public void testSourcePositioned() throws Exception {
GinjectorBindings parent = control.createMock("parent", GinjectorBindings.class);
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE), new Dependency(foo(), bar(), SOURCE)));
expect(origin.isBound(foo())).andReturn(true).anyTimes();
expect(origin.isBound(bar())).andReturn(false).anyTimes();
expect(origin.isPinned(foo())).andReturn(true).anyTimes();
expect(origin.isPinned(bar())).andReturn(false).anyTimes();
expect(origin.getParent()).andReturn(parent).anyTimes();
expect(parent.getParent()).andReturn(null).times(2);
expect(parent.isBound(foo())).andReturn(false);
expect(parent.isPinned(foo())).andReturn(false);
expect(parent.isBound(bar())).andReturn(true);
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertSame(origin, output.getPreExistingLocations().get(foo()));
assertSame(parent, output.getPreExistingLocations().get(bar()));
control.verify();
}
use of com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput in project google-gin by gwtplus.
the class DependencyExplorerTest method testAlreadyPositioned.
public void testAlreadyPositioned() throws Exception {
expect(origin.getDependencies()).andStubReturn(TestUtils.dependencyList(new Dependency(Dependency.GINJECTOR, foo(), SOURCE)));
expect(origin.isBound(foo())).andReturn(true).anyTimes();
expect(origin.getParent()).andReturn(null);
control.replay();
DependencyExplorerOutput output = dependencyExplorer.explore(origin);
assertSame(origin, output.getPreExistingLocations().get(foo()));
assertEquals(1, output.getPreExistingLocations().size());
assertEmpty(output.getBindingErrors());
assertEmpty(output.getImplicitlyBoundKeys());
assertSame(origin, output.getGraph().getOrigin());
assertEmpty(output.getGraph().getDependenciesOf(foo()));
assertContentsAnyOrder(output.getGraph().getDependenciesTargeting(foo()), new Dependency(Dependency.GINJECTOR, foo(), SOURCE));
control.verify();
}
Aggregations