@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 loggingTests_withImplicitPluginDependency() throws Exception { DependencyList depList = new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, true); depList.processDep("foo/plugin!foo/bar", explicitDeps, null, new HashSet<String>(), null); assertEquals(2, explicitDeps.size()); assertEquals(Messages.DependencyList_1, explicitDeps.get("foo/plugin").getComment()); assertEquals( MessageFormat.format(Messages.DependencyList_5, "test"), explicitDeps.get("foo/plugin!foo/bar").getComment()); }
@Test public void loggingTests_simple() throws Exception { DependencyList depList = new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, true); depList.processDep("foo/test", explicitDeps, null, new HashSet<String>(), null); assertEquals(1, explicitDeps.size()); assertEquals( new HashSet<String>(Arrays.asList(new String[] {"foo/test"})), explicitDeps.getModuleIds()); assertEquals( MessageFormat.format(Messages.DependencyList_5, "test"), explicitDeps.get("foo/test").getComment().trim()); }
@Test public void loggingTests_withHasBranching() throws Exception { DependencyList depList = new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, true); depList.processDep( "dojo/has!test?foo/test:bar/test", explicitDeps, null, new HashSet<String>(), null); assertEquals(3, explicitDeps.size()); assertEquals(Messages.DependencyList_1, explicitDeps.get("dojo/has").getComment()); String msg = MessageFormat.format( Messages.DependencyList_2, new Object[] {"dojo/has!test?foo/test:bar/test"}); assertEquals(msg, explicitDeps.get("foo/test").getComment()); assertEquals(msg, explicitDeps.get("bar/test").getComment()); }
@Test public void loggingTests_withAliasing() throws Exception { DependencyList depList = new DependencyList("test", new HashSet<String>(), mockAggregator, features, true, true); configRef.set(new ConfigImpl(mockAggregator, tmpDir, "{aliases:[['foo/test', 'foo/bar']]}")); depList.processDep("foo/test", explicitDeps, null, new HashSet<String>(), null); assertEquals(1, explicitDeps.size()); assertEquals( new HashSet<String>(Arrays.asList(new String[] {"foo/bar"})), explicitDeps.getModuleIds()); assertEquals( MessageFormat.format(Messages.DependencyList_5, "test") + ", Aliased from: foo/test --> foo/bar", explicitDeps.get("foo/bar").getComment()); }
@Test public void hasBranchingDisabledTests_withDefinedFeature() 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); depList.processDep( "dojo/has!test?foo/test:bar/test", explicitDeps, null, new HashSet<String>(), null); assertEquals(2, explicitDeps.size()); assertEquals( new HashSet<String>(Arrays.asList(new String[] {"dojo/has", "foo/test"})), explicitDeps.getModuleIds()); assertEquals( new HashSet<String>(Arrays.asList(new String[] {"test"})), 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()); }