Search in sources :

Example 1 with DependencyExplorerOutput

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();
}
Also used : DependencyExplorerOutput(com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput) Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 2 with DependencyExplorerOutput

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();
}
Also used : DependencyExplorerOutput(com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput) Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 3 with DependencyExplorerOutput

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();
}
Also used : DependencyExplorerOutput(com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput) Dependency(com.google.gwt.inject.rebind.binding.Dependency) BindingCreationException(com.google.gwt.inject.rebind.resolution.ImplicitBindingCreator.BindingCreationException)

Example 4 with DependencyExplorerOutput

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();
}
Also used : GinjectorBindings(com.google.gwt.inject.rebind.GinjectorBindings) DependencyExplorerOutput(com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput) Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Example 5 with DependencyExplorerOutput

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();
}
Also used : DependencyExplorerOutput(com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput) Dependency(com.google.gwt.inject.rebind.binding.Dependency)

Aggregations

DependencyExplorerOutput (com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput)11 Dependency (com.google.gwt.inject.rebind.binding.Dependency)10 GinjectorBindings (com.google.gwt.inject.rebind.GinjectorBindings)6 TreeLogger (com.google.gwt.core.ext.TreeLogger)1 BindingCreationException (com.google.gwt.inject.rebind.resolution.ImplicitBindingCreator.BindingCreationException)1 InvalidKeys (com.google.gwt.inject.rebind.resolution.UnresolvedBindingValidator.InvalidKeys)1