TypescriptInputReader { public void read(String filename) { FileSystemUtil.assertFileOrResourceExists(filename); TypescriptProject bean = readFile(filename); mapInput(bean); } TypescriptInputReader(DependencyGraph dependencyGraph); void read(String filename); static final String ROOT_NODE_NAME; static final String PARENT_PROPERTY; }
@Test public void read() { TypescriptInputReader reader = new TypescriptInputReader(dependencyGraph); reader.read("src/test/resources/typescript/ts-qav-export.xml"); assertThat(dependencyGraph.getAllNodes().size()).isEqualTo(1588); assertThat(dependencyGraph.getAllEdges().size()).isGreaterThan(1588); Node n1 = dependencyGraph.getNode("src/dataModel/AliasNode.ts#AliasNode#original"); assertThat(n1).isNotNull(); assertThat(n1.getProperty("typescript-parent")).isEqualTo("src/dataModel/AliasNode.ts"); Node n2 = dependencyGraph.getNode("src/dataModel/AliasNode.ts"); assertThat(n2).isNotNull(); assertThat(n2.getProperty("typescript-parent")).isNull(); GraphExporter.export(dependencyGraph, "build/typescript-test/ts-qav-export", new Architecture(), new ArrayList<>(), false); }
@Test public void testInitFileNotFound() { try { new TypescriptInputReader(dependencyGraph).read("not-existing-file.xml"); fail("IllegalArgumentException expected"); } catch(IllegalArgumentException e) { assertThat(e.getMessage()).startsWith("File not found: "); } }
@Test public void testReadInvalidFile() { try { new TypescriptInputReader(dependencyGraph).read("src/test/resources/typescript/not-an-xml-file.noxml"); fail("IllegalArgumentException expected"); } catch(IllegalArgumentException e) { assertThat(e.getCause()).isInstanceOf(IOException.class); assertThat(e.getMessage()).startsWith("com.fasterxml.jackson.core.JsonParseException: Unexpected close tag </invalid-end-tag>; expected </start-tag>"); } }