@Test
  public void testProcessDep_withConditionalizedAlias() throws Exception {
    DependencyList depList =
        new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, false);
    configRef.set(
        new ConfigImpl(
            mockAggregator,
            tmpDir,
            "{aliases:[[/^foo\\//, function(s){return (has('test')?'xxx':'yyy')+'/'}]]}"));
    depList.processDep("foo/test", explicitDeps, null, new HashSet<String>(), null);
    assertEquals(
        new HashSet<String>(Arrays.asList(new String[] {"yyy/test"})), explicitDeps.getModuleIds());
    assertEquals(
        new HashSet<String>(Arrays.asList(new String[] {"test"})), depList.getDependentFeatures());
    depList.getDependentFeatures().clear();

    explicitDeps = new ModuleDeps();
    features.put("test", true);
    depList.processDep("foo/test", explicitDeps, null, new HashSet<String>(), null);
    assertEquals(
        new HashSet<String>(Arrays.asList(new String[] {"xxx/test"})), explicitDeps.getModuleIds());
    assertEquals(
        new HashSet<String>(Arrays.asList(new String[] {"test"})), depList.getDependentFeatures());
    depList.getDependentFeatures().clear();

    explicitDeps = new ModuleDeps();
    features.put("test", false);
    depList.processDep("foo/test", explicitDeps, null, new HashSet<String>(), null);
    assertEquals(
        new HashSet<String>(Arrays.asList(new String[] {"yyy/test"})), explicitDeps.getModuleIds());
    assertEquals(
        new HashSet<String>(Arrays.asList(new String[] {"test"})), depList.getDependentFeatures());
  }
 @Test
 public void testProcessDep_withCompoundHasExpressionAndDefinedFeatures() throws Exception {
   // Defined features should have no impact on results.
   features.put("test", true);
   features.put("test1", false);
   features.put("test2", false);
   DependencyList depList =
       new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, false);
   depList.processDep(
       "dojo/has!test?test1?foo1/test:bar1/test:test2:foo2/test:bar2/test",
       explicitDeps,
       null,
       new HashSet<String>(),
       null);
   assertEquals(5, explicitDeps.size());
   assertEquals(
       new HashSet<String>(
           Arrays.asList(
               new String[] {
                 "dojo/has",
                 "dojo/has!test?test1?foo1/test",
                 "dojo/has!test?test1?:bar1/test",
                 "dojo/has!test?:test2?foo2/test",
                 "dojo/has!test?:test2?:bar2/test"
               })),
       explicitDeps.getModuleIds());
   assertEquals(
       new HashSet<String>(Arrays.asList(new String[] {"test", "test1", "test2"})),
       depList.getDependentFeatures());
 }
 @Test
 public void testProcessDep_withAliasResolutionUsingDefinedFeatures1() throws Exception {
   DependencyList depList =
       new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, false);
   features.put("testFoo", true);
   features.put("testBar", false);
   configRef.set(
       new ConfigImpl(
           mockAggregator,
           tmpDir,
           "{aliases:[[/^foo\\//, function(s){return (has('testFoo')?'xxx':'yyy')+'/'}],[/^bar\\//, function(s){return (has('testBar')?'www':'zzz')+'/'}]]}"));
   depList.processDep("bar/plugin!foo/test", explicitDeps, null, new HashSet<String>(), null);
   assertEquals(
       new HashSet<String>(Arrays.asList(new String[] {"zzz/plugin!xxx/test", "zzz/plugin"})),
       explicitDeps.getModuleIds());
   assertEquals(
       new HashSet<String>(Arrays.asList(new String[] {"testFoo", "testBar"})),
       depList.getDependentFeatures());
 }
 public void hasBranchingDisabledTests_withDefinedFeatures() throws Exception {
   mockAggregator.getOptions().setOption(IOptions.DISABLE_HASPLUGINBRANCHING, true);
   DependencyList depList =
       new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, false);
   features.put("test", true);
   features.put("test1", true);
   depList.processDep(
       "dojo/has!test?test1?foo1/test:bar1/test:test2:foo2/test:bar2/test",
       explicitDeps,
       null,
       new HashSet<String>(),
       null);
   assertEquals(2, explicitDeps.size());
   assertEquals(
       new HashSet<String>(Arrays.asList(new String[] {"dojo/has", "foo1/test"})),
       explicitDeps.getModuleIds());
   assertEquals(
       new HashSet<String>(Arrays.asList(new String[] {"test", "test1"})),
       depList.getDependentFeatures());
 }
 @Test
 public void resolveAliasesDisabledAndHasBranchingDisabled_withDefinedFeatures() throws Exception {
   mockAggregator.getOptions().setOption(IOptions.DISABLE_HASPLUGINBRANCHING, true);
   configRef.set(new ConfigImpl(mockAggregator, tmpDir, "{aliases:[['foo1/test', 'bar/test']]}"));
   DependencyList depList =
       new DependencyList("test", new HashSet<String>(), mockAggregator, features, false, false);
   features.put("test", true);
   features.put("test1", true);
   depList.processDep(
       "dojo/has!test?test1?foo1/test:bar1/test:test2:foo2/test:bar2/test",
       explicitDeps,
       null,
       new HashSet<String>(),
       null);
   assertEquals(2, explicitDeps.size());
   assertEquals(
       new HashSet<String>(Arrays.asList(new String[] {"dojo/has", "foo1/test"})),
       explicitDeps.getModuleIds());
   assertEquals(
       new HashSet<String>(Arrays.asList(new String[] {"test", "test1"})),
       depList.getDependentFeatures());
 }