ModuleDependencyResolutionStrategy implements ResolutionStrategy { @Override public Set<Name> resolve(Set<Name> modules, final Name context) { if (modules.contains(context)) { return ImmutableSet.of(context); } return ImmutableSet.copyOf(Collections2.filter(modules, input -> dependencyProvider.dependencyExists(context, input))); } @Deprecated  ModuleDependencyResolutionStrategy(ModuleEnvironment environment);  ModuleDependencyResolutionStrategy(ModuleDependencyProvider dependencyProvider); @Override Set<Name> resolve(Set<Name> modules, final Name context);  }
@Test public void resolveNoOptions() { ModuleEnvironment environment = TestModulesUtil.createEnvironment(); ModuleDependencyResolutionStrategy strategy = new ModuleDependencyResolutionStrategy(environment); assertEquals(Collections.<Name>emptySet(), strategy.resolve(Collections.<Name>emptySet(), Name.EMPTY)); }
@Test public void resolveSingleOptionOutsideOfContextAndDependencies() { ModuleEnvironment environment = TestModulesUtil.createEnvironment(); ModuleDependencyResolutionStrategy strategy = new ModuleDependencyResolutionStrategy(environment); assertEquals(Collections.<Name>emptySet(), strategy.resolve(ImmutableSet.of(new Name("Cats")), Name.EMPTY)); }
@Test public void resolveReturnsContextIfPresent() { ModuleEnvironment environment = TestModulesUtil.createEnvironment(TEST_MODULE, MODULE_A); ModuleDependencyResolutionStrategy strategy = new ModuleDependencyResolutionStrategy(environment); assertEquals(ImmutableSet.of(TEST_MODULE), strategy.resolve(ImmutableSet.of(TEST_MODULE, MODULE_A), TEST_MODULE)); }
@Test public void resolveReturnsOnlyDependenciesOfContext() { ModuleEnvironment environment = TestModulesUtil.createEnvironment(TEST_MODULE, MODULE_A); ModuleDependencyResolutionStrategy strategy = new ModuleDependencyResolutionStrategy(environment); assertEquals(ImmutableSet.of(TEST_MODULE), strategy.resolve(ImmutableSet.of(TEST_MODULE, new Name("Cat")), MODULE_A)); }