ClosureRequireDependencyManager { @Nonnull public Node addFile(@Nonnull String path, @Nonnull File javascriptFile, @Nonnull Set<String> notMinimized) throws IOException { String javascript = Files.toString(javascriptFile, Charset.forName(ENCODING)); return addFile(path, javascript, notMinimized); }  @Nonnull Node addFile(@Nonnull String path, @Nonnull File javascriptFile, @Nonnull Set<String> notMinimized); @Nonnull Node addFile(@Nonnull String path, @Nonnull String javascript, @Nonnull Set<String> notMinimized); Collection<Node> getTransitiveDependenciesFor(String moduleId, boolean includeSelf); Set<String> getAllModuleIds(); Node getNode(String moduleId); void validateGraph();  }
@Test(expected = IllegalArgumentException.class) public void testAddFileDuplicateModuleId() throws Exception { _depManager.addFile("abc", "goog.provide('1a')", Collections.<String>emptySet()); }
@Test(expected = IllegalArgumentException.class) public void testAddFileNoProvideString() throws Exception { _depManager.addFile("abc", "goog.provide()", Collections.<String>emptySet()); }
@Test(expected = IllegalArgumentException.class) public void testAddFileNoRequireString() throws Exception { _depManager.addFile("abc", "goog.require('qrt)", Collections.<String>emptySet()); }
@Test(expected = IllegalArgumentException.class) public void testAddFileEmptyProvideString() throws Exception { _depManager.addFile("abc", "goog.provide('')", Collections.<String>emptySet()); }
@Test(expected = IllegalArgumentException.class) public void testAddFileEmptyRequireString() throws Exception { _depManager.addFile("abc", "goog.require('')", Collections.<String>emptySet()); }
@Test public void testAddFileNoProvide() throws Exception { final ClosureRequireDependencyManager.Node abc = _depManager.addFile("qrt/abc.js", "goog.require('ab2'", Collections.<String>emptySet()); assertEquals("abc", abc.id); }
@Test public void testAddFileRequiresUsesDoubleQuotes() throws Exception { final ClosureRequireDependencyManager.Node node = _depManager.addFile("xb", "goog.provide('xb'); goog.require(\"3a\")", Collections.<String>emptySet()); assertTrue(node.dependencyIds.contains("3a")); }
@Test public void testAddFileProvidesCanBeDeclaredAfterRequire() throws Exception { final ClosureRequireDependencyManager.Node node = _depManager.addFile("xb", "goog.require('3a'); goog.provide('xb');", Collections.<String>emptySet()); Assert.assertEquals("xb", node.id); assertTrue(node.dependencyIds.contains("3a")); }
@Test public void testLineEndingInRequireAndProvide() throws Exception { final ClosureRequireDependencyManager.Node node = _depManager.addFile("xb", "goog.\nrequire('3a'); goog.\n\rprovide('xb');", Collections.<String>emptySet()); Assert.assertEquals("xb", node.id); assertTrue(node.dependencyIds.contains("3a")); }
@Test public void testLineEndingInRequireAndProvide2() throws Exception { final ClosureRequireDependencyManager.Node node = _depManager.addFile("xb", "goog\n.require('3a'); goog\n.\rprovide('xb');", Collections.<String>emptySet()); Assert.assertEquals("xb", node.id); assertTrue(node.dependencyIds.contains("3a")); }
@Test public void testFindTransitiveDependenciesFor() throws Exception { ClosureRequireDependencyManager.Node node = _depManager.addFile("xb", "goog.provide('xb');", Collections.singleton("xb")); Assert.assertEquals("xb", node.id); assertFalse(node.isMinimized); assertTrue(node.dependencyIds.isEmpty()); node = _depManager.addFile("xc", "goog.provide('xc');", Collections.singleton("xb")); Assert.assertEquals("xc", node.id); assertTrue(node.isMinimized); assertTrue(node.dependencyIds.isEmpty()); }