diff --git a/dumpAst.base/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java b/dumpAst.base/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java index 251055a5f7a014c9225f39ba16721826622cbd9e..ed87cf24a45c0d9c8cda43c612c4450080fc8504 100644 --- a/dumpAst.base/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java +++ b/dumpAst.base/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/DumpBuilder.java @@ -666,19 +666,28 @@ public class DumpBuilder { // --- Dump methods --- + /** + * Return content as plantuml source code. + * + * @return the plantuml source code + * @throws TransformationException if {@link DumpAst#transform(TransformationTransferInformation, Object) transform} was not successful + */ + public String dumpAsSource() throws TransformationException { + return build().toPlantUml(); + } + /** * Write out content as plantuml source code. * * @param destination path of destination file - * @return this - * @throws java.io.IOException if an I/O error happened during opening or writing in that file + * @throws IOException if an I/O error happened during opening or writing in that file + * @throws TransformationException if {@link DumpAst#transform(TransformationTransferInformation, Object) transform} was not successful */ - public DumpBuilder dumpAsSource(Path destination) throws java.io.IOException { + public void dumpAsSource(Path destination) throws IOException, TransformationException { String content = build().toPlantUml(); try (Writer writer = Files.newBufferedWriter(destination)) { writer.write(content); } - return this; } /** @@ -686,39 +695,36 @@ public class DumpBuilder { * * @param destination path of destination file * @param prependCreationComment whether to add the creation date as first line - * @return this - * @throws java.io.IOException if an I/O error happened during opening or writing in that file + * @throws IOException if an I/O error happened during opening or writing in that file + * @throws TransformationException if {@link DumpAst#transform(TransformationTransferInformation, Object) transform} was not successful */ - public DumpBuilder dumpAsYaml(Path destination, boolean prependCreationComment) throws java.io.IOException { + public void dumpAsYaml(Path destination, boolean prependCreationComment) throws IOException, TransformationException { String content = build().printYaml(prependCreationComment); try (Writer writer = Files.newBufferedWriter(destination)) { writer.write(content); } - return this; } /** * Write out content as PNG image generated by plantuml. * * @param destination path of destination file - * @return this - * @throws java.io.IOException if an I/O error happened during opening or writing in that file + * @throws IOException if an I/O error happened during opening or writing in that file + * @throws TransformationException if {@link DumpAst#transform(TransformationTransferInformation, Object) transform} was not successful */ - public DumpBuilder dumpAsPNG(Path destination) throws java.io.IOException { + public void dumpAsPNG(Path destination) throws IOException, TransformationException { dumpAs(destination, FileFormat.PNG); - return this; } /** * Write out content as SVG image generated by plantuml. * * @param destination path of destination file - * @return this - * @throws java.io.IOException if an I/O error happened during opening or writing in that file + * @throws IOException if an I/O error happened during opening or writing in that file + * @throws TransformationException if {@link DumpAst#transform(TransformationTransferInformation, Object) transform} was not successful */ - public DumpBuilder dumpAsSVG(Path destination) throws java.io.IOException { + public void dumpAsSVG(Path destination) throws IOException, TransformationException { dumpAs(destination, FileFormat.SVG); - return this; } /** @@ -728,15 +734,14 @@ public class DumpBuilder { * <b>Note:</b> This requires additional dependencies, see <a href="https://plantuml.com/pdf">https://plantuml.com/pdf</a> * * @param destination path of destination file - * @return this - * @throws java.io.IOException if an I/O error happened during opening or writing in that file + * @throws IOException if an I/O error happened during opening or writing in that file + * @throws TransformationException if {@link DumpAst#transform(TransformationTransferInformation, Object) transform} was not successful */ - public DumpBuilder dumpAsPDF(Path destination) throws java.io.IOException { + public void dumpAsPDF(Path destination) throws IOException, TransformationException { dumpAs(destination, FileFormat.PDF); - return this; } - private void dumpAs(Path destination, FileFormat fileFormat) throws IOException { + private void dumpAs(Path destination, FileFormat fileFormat) throws IOException, TransformationException { String content = build().toPlantUml(); SourceStringReader reader = new SourceStringReader(content); reader.outputImage(Files.newOutputStream(destination), new FileFormatOption(fileFormat)); @@ -744,7 +749,7 @@ public class DumpBuilder { // --- Helper methods --- - protected DumpAst build() { + protected DumpAst build() throws TransformationException { if (result == null) { result = new DumpAst(); final String packageNameToUse; @@ -763,7 +768,8 @@ public class DumpBuilder { try { result.transform(new TransformationTransferInformation(), this.target); } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { - throw new RuntimeException("Could not transform :(", e); + result = null; + throw new TransformationException(e); } } return result; diff --git a/dumpAst.base/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/TransformationException.java b/dumpAst.base/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/TransformationException.java new file mode 100644 index 0000000000000000000000000000000000000000..9e36e7a679960819faad10767441f73b281f9616 --- /dev/null +++ b/dumpAst.base/src/main/java/de/tudresden/inf/st/jastadd/dumpAst/ast/TransformationException.java @@ -0,0 +1,12 @@ +package de.tudresden.inf.st.jastadd.dumpAst.ast; + +/** + * Exception when transformation was unsuccessful. + * + * @author rschoene - Initial contribution + */ +public class TransformationException extends Exception { + public TransformationException(Throwable cause) { + super("Could not transform :(", cause); + } +} diff --git a/dumpAst.base/src/main/resources/dumpAstVersion.properties b/dumpAst.base/src/main/resources/dumpAstVersion.properties index dd0adf1695b118450b79cf06a51d33c090308347..810cb294c4f21dbbf55024b562596a4775489dbd 100644 --- a/dumpAst.base/src/main/resources/dumpAstVersion.properties +++ b/dumpAst.base/src/main/resources/dumpAstVersion.properties @@ -1,2 +1,2 @@ -#Tue Sep 06 14:11:59 CEST 2022 -version=1.2.2 +#Thu Sep 08 16:46:11 CEST 2022 +version=2.0.0 diff --git a/dumpAst.prototyping/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java b/dumpAst.prototyping/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java index bc1d3729b387006b105e9b23a1670c4c818706e9..5e758f933eedc650948ffca0992da3df19f9332b 100644 --- a/dumpAst.prototyping/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java +++ b/dumpAst.prototyping/src/main/java/de/tudresden/inf/st/jastadd/featureTest/FeatureTestMain.java @@ -1,7 +1,9 @@ package de.tudresden.inf.st.jastadd.featureTest; +import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpBuilder; import de.tudresden.inf.st.jastadd.dumpAst.ast.Dumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.SkinParamBooleanSetting; +import de.tudresden.inf.st.jastadd.dumpAst.ast.TransformationException; import org.jastadd.featureTest.ast.*; import java.io.IOException; @@ -15,7 +17,7 @@ import java.nio.file.Paths; */ public class FeatureTestMain { - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws IOException, TransformationException { Root root = new Root(); root.setName("Root1"); A a = new A().setName("A2"); @@ -38,9 +40,10 @@ public class FeatureTestMain { Path pathToYaml = Paths.get("featureTest.yml"); Path pathToPng = Paths.get("featureTest.png"); Path pathToSvg = Paths.get("featureTest.svg"); - Dumper + DumpBuilder builder = Dumper // .read(null) .read(root) +// .enableRelationWithRank() // .customPreamble("hide empty members") .enableDebug() .customPreamble("title My fancy title") @@ -66,12 +69,11 @@ public class FeatureTestMain { } }) .skinParam(SkinParamBooleanSetting.Shadowing, false) - .setNameMethod(node -> node.getClass().getSimpleName() + ASTNode.counter++) -// .enableRelationWithRank() - .dumpAsYaml(pathToYaml, true) - .dumpAsPNG(pathToPng) - .dumpAsSVG(pathToSvg) - .dumpAsSource(Paths.get("featureTest.puml")) - ; + .setNameMethod(node -> node.getClass().getSimpleName() + ASTNode.counter++); + + builder.dumpAsYaml(pathToYaml, true); + builder.dumpAsPNG(pathToPng); + builder.dumpAsSVG(pathToSvg); + builder.dumpAsSource(Paths.get("featureTest.puml")); } } diff --git a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestComplex.java b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestComplex.java index 856bab384ff5d2ade9b7dacf4704a0a5e90cc648..574ec066d9d04d22bfc0f3662058f0960c516d20 100644 --- a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestComplex.java +++ b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestComplex.java @@ -1,6 +1,7 @@ package de.tudresden.inf.st.jastadd.testDumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; +import de.tudresden.inf.st.jastadd.dumpAst.ast.TransformationException; import org.jastadd.testDumper.ast.DropOffLocation; import org.jastadd.testDumper.ast.Orientation; import org.jastadd.testDumper.ast.Position; @@ -20,7 +21,7 @@ import static org.assertj.core.api.Assertions.*; public class TestComplex { @Test - public void testRegressionIssue16() { + public void testRegressionIssue16() throws TransformationException { DropOffLocation location = new DropOffLocation(); location.setName(ROOT_NAME); location.setPosition(new Position(T1_NAME, 1, 2, 3)); diff --git a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestExcluded.java b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestExcluded.java index a122a05519a8a68e5b3963b3ff30da13b2cca86a..23d161c3f760e74ec0e2f398ef7f4fd7e73185bd 100644 --- a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestExcluded.java +++ b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestExcluded.java @@ -3,6 +3,7 @@ package de.tudresden.inf.st.jastadd.testDumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpBuilder; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; import de.tudresden.inf.st.jastadd.dumpAst.ast.Dumper; +import de.tudresden.inf.st.jastadd.dumpAst.ast.TransformationException; import org.jastadd.testDumper.ast.A; import org.jastadd.testDumper.ast.Root; import org.junit.jupiter.api.Disabled; @@ -18,7 +19,7 @@ import static org.assertj.core.api.Assertions.*; public class TestExcluded { @Test - public void testEmptyStringsOnTokensDefault() { + public void testEmptyStringsOnTokensDefault() throws TransformationException { Root root = createRoot(null, null, createB(B1_NAME, "something"), createB(B2_NAME), createB(B3_NAME)); // normal mode, do not include empty strings @@ -33,7 +34,7 @@ public class TestExcluded { } @Test - public void testEmptyStringsOnTokensIncluded() { + public void testEmptyStringsOnTokensIncluded() throws TransformationException { Root root = createRoot(null, null, createB(B1_NAME, "something"), createB(B2_NAME), createB(B3_NAME)); // test mode, do include empty strings @@ -66,7 +67,7 @@ public class TestExcluded { } @Test - public void testTypesDefault() { + public void testTypesDefault() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -90,7 +91,7 @@ public class TestExcluded { } @Test - public void testTypesNonMatching() { + public void testTypesNonMatching() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.disableTypes("NonExistingType")); @@ -99,7 +100,7 @@ public class TestExcluded { } @Test - public void testTypesInheritanceNotIncluded() { + public void testTypesInheritanceNotIncluded() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.disableTypes("Nameable")); @@ -108,7 +109,7 @@ public class TestExcluded { } @Test - public void testTypesExcludeOnlyA() { + public void testTypesExcludeOnlyA() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.disableTypes("A")); @@ -123,7 +124,7 @@ public class TestExcluded { } @Test - public void testTypesExcludeMultipleArguments() { + public void testTypesExcludeMultipleArguments() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.disableTypes("A", "C")); @@ -133,7 +134,7 @@ public class TestExcluded { } @Test - public void testTypesExcludeMultipleCalls() { + public void testTypesExcludeMultipleCalls() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.disableTypes("A").disableTypes("C")); @@ -143,7 +144,7 @@ public class TestExcluded { } @Test - public void testTypesExcludeRegex() { + public void testTypesExcludeRegex() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.disableTypes("Ro*t")); @@ -152,7 +153,7 @@ public class TestExcluded { } @Test - public void testTypesInvisiblePath() { + public void testTypesInvisiblePath() throws TransformationException { final String A2_Name = "a2"; final String A3_Name = "a3"; final String C2_Name = "c2"; @@ -169,7 +170,7 @@ public class TestExcluded { } @Test - public void testTokenDefault() { + public void testTokenDefault() throws TransformationException { A a = createA(A_NAME); Root root = createRoot(a, createC(C_NAME, c -> { c.setRawReference(a); @@ -189,7 +190,7 @@ public class TestExcluded { } @Test - public void testTokenExcludeValue() { + public void testTokenExcludeValue() throws TransformationException { A a = createA(A_NAME); Root root = createRoot(a, createC(C_NAME, c -> { c.setRawReference(a); @@ -209,7 +210,7 @@ public class TestExcluded { } @Test - public void testTokenExcludeValueAndReference() { + public void testTokenExcludeValueAndReference() throws TransformationException { A a = createA(A_NAME); Root root = createRoot(a, createC(C_NAME, c -> { c.setRawReference(a); @@ -229,7 +230,7 @@ public class TestExcluded { } @Test - public void testTokenExcludeRelationNameLowerCase() { + public void testTokenExcludeRelationNameLowerCase() throws TransformationException { A a = createA(A_NAME); Root root = createRoot(a, createC(C_NAME, c -> { c.setRawReference(a); @@ -249,7 +250,7 @@ public class TestExcluded { } @Test - public void testTokenExcludeRelationNameTitleCase() { + public void testTokenExcludeRelationNameTitleCase() throws TransformationException { A a = createA(A_NAME); Root root = createRoot(a, createC(C_NAME, c -> { c.setRawReference(a); @@ -270,7 +271,7 @@ public class TestExcluded { } @Test - public void testChildrenDefault() { + public void testChildrenDefault() throws TransformationException { /* Root |- a |- b - - -. @@ -295,7 +296,7 @@ public class TestExcluded { } @Test - public void testChildrenExclude() { + public void testChildrenExclude() throws TransformationException { /* Root |- a |- b - - -. @@ -319,7 +320,7 @@ public class TestExcluded { } @Test - public void testRelationsDefault() { + public void testRelationsDefault() throws TransformationException { // actually the same test as #testTypesDefault, but can't hurt to test twice Root root = setupAllRelations(); @@ -329,7 +330,7 @@ public class TestExcluded { } @Test - public void testRelationsExclude() { + public void testRelationsExclude() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.excludeRelations("BiC1")); @@ -348,7 +349,7 @@ public class TestExcluded { } @Test - public void testRelationsExcludeRegex1() { + public void testRelationsExcludeRegex1() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.excludeRelations("Bi.*")); @@ -365,7 +366,7 @@ public class TestExcluded { } @Test - public void testRelationsExcludeRegex2() { + public void testRelationsExcludeRegex2() throws TransformationException { Root root = setupAllRelations(); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.excludeRelations(".*A.*")); diff --git a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java index 0d5dce44733c11890fa8d345c310c3fcbe1ead61..4d9d20e75ecb438ed0b21c04d898ec7384c6b0d4 100644 --- a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java +++ b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestIncluded.java @@ -1,6 +1,7 @@ package de.tudresden.inf.st.jastadd.testDumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; +import de.tudresden.inf.st.jastadd.dumpAst.ast.TransformationException; import org.jastadd.testDumper.ast.Root; import org.junit.jupiter.api.Test; @@ -12,7 +13,7 @@ import static org.assertj.core.api.Assertions.*; public class TestIncluded { @Test - public void testValueAttributeDefault() { + public void testValueAttributeDefault() throws TransformationException { Root root = createRoot(null, null); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -22,7 +23,7 @@ public class TestIncluded { } @Test - public void testValueAttributeIncluded() { + public void testValueAttributeIncluded() throws TransformationException { Root root = createRoot(null, null); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeAttributes("simpleAttr")); @@ -32,7 +33,7 @@ public class TestIncluded { } @Test - public void testReferenceListAttributeIncluded() { + public void testReferenceListAttributeIncluded() throws TransformationException { Root root = createRoot(null, null, createB(B1_NAME), createB(B2_NAME), createB(B3_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeAttributes("setOfBs")); @@ -44,7 +45,7 @@ public class TestIncluded { } @Test - public void testReferenceAttributeDefault() { + public void testReferenceAttributeDefault() throws TransformationException { Root root = createRoot(createA(A_NAME), null); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -54,7 +55,7 @@ public class TestIncluded { } @Test - public void testReferenceAttributeIncluded() { + public void testReferenceAttributeIncluded() throws TransformationException { Root root = createRoot(createA(A_NAME), null); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeAttributes("referenceAttr")); @@ -64,7 +65,7 @@ public class TestIncluded { } @Test - public void testNormalNTADefault() { + public void testNormalNTADefault() throws TransformationException { Root root = createRoot(null, createC(C_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -74,7 +75,7 @@ public class TestIncluded { } @Test - public void testNormalNTAIncluded() { + public void testNormalNTAIncluded() throws TransformationException { Root root = createRoot(null, createC(C_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeNonterminalAttributes("Calculated")); @@ -84,7 +85,7 @@ public class TestIncluded { } @Test - public void testListNTADefault() { + public void testListNTADefault() throws TransformationException { Root root = createRoot(null, createC(C_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -95,7 +96,7 @@ public class TestIncluded { } @Test - public void testListNTAIncluded() { + public void testListNTAIncluded() throws TransformationException { Root root = createRoot(null, createC(C_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root, db -> db.includeNonterminalAttributes("AlsoCalculated")); diff --git a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java index 752e6ce02448417115b276d81152217514769ea8..6d6294bea952209adffda3e65963e297e07f51dd 100644 --- a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java +++ b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestSimple.java @@ -3,6 +3,7 @@ package de.tudresden.inf.st.jastadd.testDumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpAst; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpBuilder; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; +import de.tudresden.inf.st.jastadd.dumpAst.ast.TransformationException; import org.jastadd.testDumper.ast.*; import org.junit.jupiter.api.Test; @@ -20,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.*; public class TestSimple { @Test - public void testEmpty() { + public void testEmpty() throws TransformationException { Root root = createRoot(null, null); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -32,7 +33,7 @@ public class TestSimple { } @Test - public void testCustomPreamble() throws IOException { + public void testCustomPreamble() throws IOException, TransformationException { Root root = createRoot(null, null); String preamble = "{<\n>\n}"; ExposingDumpBuilder builder = new ExposingDumpBuilder(root); @@ -47,7 +48,7 @@ public class TestSimple { assertThat(puml).contains(preamble); } - @Test void testChildlessNonterminal() { + @Test void testChildlessNonterminal() throws TransformationException { Root root = createRoot(createA(A_NAME, a -> a.setD(new D())), null); List<DumpNode> nodes = TestUtils.dumpModel(root); Optional<DumpNode> actualD = nodes.stream().filter(n -> n.getObject() instanceof D).findFirst(); @@ -56,7 +57,7 @@ public class TestSimple { } @Test - public void testOneNormalChild() { + public void testOneNormalChild() throws TransformationException { Root root = createRoot(createA(A_NAME), null); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -69,7 +70,7 @@ public class TestSimple { } @Test - public void testOneNormalChildIncludeNullNodes() { + public void testOneNormalChildIncludeNullNodes() throws TransformationException { Root root = createRoot(createA(A_NAME), null); List<DumpNode> nodes = TestUtils.dumpModel(root, DumpBuilder::includeNullNodes); @@ -95,7 +96,7 @@ public class TestSimple { } @Test - public void testListChildren() { + public void testListChildren() throws TransformationException { Root root = createRoot(null, null, createB(B1_NAME), createB(B2_NAME), createB(B3_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -108,7 +109,7 @@ public class TestSimple { } @Test - public void testOrderedListChildren() { + public void testOrderedListChildren() throws TransformationException { Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B1_NAME), createB(B2_NAME), createB(B3_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root, DumpBuilder::orderChildren); @@ -144,7 +145,7 @@ public class TestSimple { } @Test - public void testNoOptChild() { + public void testNoOptChild() throws TransformationException { Root root = new Root().setName(ROOT_NAME); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -157,7 +158,7 @@ public class TestSimple { } @Test - public void testOneOptChild() { + public void testOneOptChild() throws TransformationException { Root root = createRoot(null, createC(C_NAME)); List<DumpNode> nodes = TestUtils.dumpModel(root); @@ -170,7 +171,7 @@ public class TestSimple { } @Test - public void testNormalUniRelation() { + public void testNormalUniRelation() throws TransformationException { Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B_NAME)); root.getB(0).setOneA(root.getA()); @@ -181,7 +182,7 @@ public class TestSimple { } @Test - public void testListUniRelation() { + public void testListUniRelation() throws TransformationException { final String A2_NAME = "anotherA"; Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B_NAME)); root.getC().setA(createA(A2_NAME)); @@ -195,7 +196,7 @@ public class TestSimple { } @Test - public void testOptUniRelation() { + public void testOptUniRelation() throws TransformationException { Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B_NAME)); root.getB(0).setMaybeC(root.getC()); @@ -206,7 +207,7 @@ public class TestSimple { } @Test - public void testNormalBiRelation() { + public void testNormalBiRelation() throws TransformationException { Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B_NAME)); root.getC().setBiA1(root.getA()); @@ -220,7 +221,7 @@ public class TestSimple { } @Test - public void testListBiRelation() { + public void testListBiRelation() throws TransformationException { Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B_NAME)); root.getC().addBiA2(root.getA()); @@ -234,7 +235,7 @@ public class TestSimple { } @Test - public void testOptBiRelation() { + public void testOptBiRelation() throws TransformationException { Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B_NAME)); root.getC().setBiA3(root.getA()); @@ -248,7 +249,7 @@ public class TestSimple { } @Test - public void testOneNormalReferenceToken() { + public void testOneNormalReferenceToken() throws TransformationException { Root root = createRoot(createA(A_NAME), createC(C_NAME), createB(B_NAME)); root.getC().setRawReference(root.getA()); @@ -259,7 +260,7 @@ public class TestSimple { } @Test - public void testChildrenReorder1() { + public void testChildrenReorder1() throws TransformationException { C subC = new SubC(); subC.setName(C_NAME); subC.setUnwanted(5); @@ -277,7 +278,7 @@ public class TestSimple { } @Test - public void testLabel() { + public void testLabel() throws TransformationException { Root root = createRoot(createA(A_NAME), null); List<DumpNode> nodes = TestUtils.dumpModel(root, @@ -290,7 +291,7 @@ public class TestSimple { } @Test - public void testTextColor() { + public void testTextColor() throws TransformationException { Root root = createRoot(createA(A_NAME), null); List<DumpNode> nodes = TestUtils.dumpModel(root, @@ -303,7 +304,7 @@ public class TestSimple { } @Test - public void testBackgroundColor() { + public void testBackgroundColor() throws TransformationException { Root root = createRoot(createA(A_NAME), null); List<DumpNode> nodes = TestUtils.dumpModel(root, diff --git a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel3.java b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel3.java index 3d37a56a6e25751f38d1bd96daa48b4ec8f16db2..50f27583960648d90ed9434df90f39729c49ae7d 100644 --- a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel3.java +++ b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel3.java @@ -1,6 +1,7 @@ package de.tudresden.inf.st.jastadd.testDumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; +import de.tudresden.inf.st.jastadd.dumpAst.ast.TransformationException; import org.jastadd.testDumper.ast.A; import org.jastadd.testDumper.ast.AbstractT; import org.jastadd.testDumper.ast.TRoot; @@ -24,7 +25,7 @@ import static org.assertj.core.api.Assertions.*; public class TestTypeLevel3 { @Test - public void testTokenLevel2Excluded() { + public void testTokenLevel2Excluded() throws TransformationException { Consumer<AbstractT> setUnwanted = t -> t.setUnwanted(5); TRoot root = createTRoot(createA(A_NAME), createT1(setUnwanted), createT2(setUnwanted), createT3(setUnwanted)); Assertions.assertEquals(5, root.getT2().getUnwanted()); @@ -38,7 +39,7 @@ public class TestTypeLevel3 { } @Test - public void testTokenLevel3SomeIncluded() { + public void testTokenLevel3SomeIncluded() throws TransformationException { Consumer<AbstractT> setUnwanted = t -> t.setUnwanted(5); TRoot root = createTRoot(createA(A_NAME), createT1(setUnwanted), createT2(setUnwanted), createT3(setUnwanted)); Assertions.assertEquals(5, root.getT2().getUnwanted()); @@ -67,7 +68,7 @@ public class TestTypeLevel3 { } @Test - public void testNormalChildLevel2Excluded() { + public void testNormalChildLevel2Excluded() throws TransformationException { Consumer<AbstractT> setB = t -> t.setB(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(setB), createT2(setB), createT3(setB)); Assertions.assertEquals(T2_NAME + B_NAME, root.getT2().getB().getName()); @@ -81,7 +82,7 @@ public class TestTypeLevel3 { } @Test - public void testNormalChildLevel3SomeIncluded() { + public void testNormalChildLevel3SomeIncluded() throws TransformationException { Consumer<AbstractT> setB = t -> t.setB(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(setB), createT2(setB), createT3(setB)); Assertions.assertEquals(T2_NAME + B_NAME, root.getT2().getB().getName()); @@ -97,7 +98,7 @@ public class TestTypeLevel3 { } @Test - public void testListChildLevel2Excluded() { + public void testListChildLevel2Excluded() throws TransformationException { Consumer<AbstractT> addBee = t -> t.addBee(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(addBee), createT2(addBee), createT3(addBee)); Assertions.assertEquals(T2_NAME + B_NAME, root.getT2().getBee(0).getName()); @@ -111,7 +112,7 @@ public class TestTypeLevel3 { } @Test - public void testListChildLevel3SomeIncluded() { + public void testListChildLevel3SomeIncluded() throws TransformationException { Consumer<AbstractT> addBee = t -> t.addBee(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(addBee), createT2(addBee), createT3(addBee)); Assertions.assertEquals(T2_NAME + B_NAME, root.getT2().getBee(0).getName()); @@ -127,7 +128,7 @@ public class TestTypeLevel3 { } @Test - public void testRelationLevel2Excluded() { + public void testRelationLevel2Excluded() throws TransformationException { final A a = createA(A_NAME); Consumer<AbstractT> setOneA = t -> t.setOneA(a); TRoot root = createTRoot(a, createT1(setOneA), createT2(setOneA), createT3(setOneA)); @@ -142,7 +143,7 @@ public class TestTypeLevel3 { } @Test - public void testRelationLevel3SomeIncluded() { + public void testRelationLevel3SomeIncluded() throws TransformationException { final A a = createA(A_NAME); Consumer<AbstractT> setOneA = t -> t.setOneA(a); TRoot root = createTRoot(a, createT1(setOneA), createT2(setOneA), createT3(setOneA)); @@ -159,7 +160,7 @@ public class TestTypeLevel3 { } @Test - public void testAttributeLevel2Included() { + public void testAttributeLevel2Included() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = dumpModel(root, @@ -175,7 +176,7 @@ public class TestTypeLevel3 { } @Test - public void testAttributeLevel3SomeExcluded() { + public void testAttributeLevel3SomeExcluded() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = dumpModel(root, @@ -191,7 +192,7 @@ public class TestTypeLevel3 { } @Test - public void testNTALevel2Included() { + public void testNTALevel2Included() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = dumpModel(root, @@ -204,7 +205,7 @@ public class TestTypeLevel3 { } @Test - public void testNTALevel3SomeExcluded() { + public void testNTALevel3SomeExcluded() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = dumpModel(root, diff --git a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel4.java b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel4.java index 489a296a2777cca1c42dda7a391ae5921ea939df..8e9220a270c3fe96df2a767d37b565f077c64d55 100644 --- a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel4.java +++ b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestTypeLevel4.java @@ -1,6 +1,7 @@ package de.tudresden.inf.st.jastadd.testDumper; import de.tudresden.inf.st.jastadd.dumpAst.ast.DumpNode; +import de.tudresden.inf.st.jastadd.dumpAst.ast.TransformationException; import org.jastadd.testDumper.ast.A; import org.jastadd.testDumper.ast.AbstractT; import org.jastadd.testDumper.ast.TRoot; @@ -23,7 +24,7 @@ import static org.assertj.core.api.Assertions.*; public class TestTypeLevel4 { @Test - public void testTokenLevel3Included() { + public void testTokenLevel3Included() throws TransformationException { Consumer<AbstractT> setUnwanted = t -> t.setUnwanted(5); TRoot root = createTRoot(createA(A_NAME, createC(C_NAME, c -> c.setUnwanted(6))), createT1(setUnwanted), createT2(setUnwanted), createT3(setUnwanted)); @@ -43,7 +44,7 @@ public class TestTypeLevel4 { } @Test - public void testTokenLevel4SomeExcluded() { + public void testTokenLevel4SomeExcluded() throws TransformationException { Consumer<AbstractT> setUnwanted = t -> t.setUnwanted(5); TRoot root = createTRoot(createA(A_NAME, createC(C_NAME, c -> c.setUnwanted(6))), createT1(setUnwanted), createT2(setUnwanted), createT3(setUnwanted)); @@ -81,7 +82,7 @@ public class TestTypeLevel4 { } @Test - public void testNormalChildLevel3Included() { + public void testNormalChildLevel3Included() throws TransformationException { Consumer<AbstractT> setB = t -> t.setB(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(setB), createT2(setB), createT3(setB)); Assertions.assertEquals(T2_NAME + B_NAME, root.getT2().getB().getName()); @@ -97,7 +98,7 @@ public class TestTypeLevel4 { } @Test - public void testNormalChildLevel4SomeExcluded() { + public void testNormalChildLevel4SomeExcluded() throws TransformationException { Consumer<AbstractT> setB = t -> t.setB(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(setB), createT2(setB), createT3(setB)); Assertions.assertEquals(T2_NAME + B_NAME, root.getT2().getB().getName()); @@ -115,7 +116,7 @@ public class TestTypeLevel4 { } @Test - public void testListChildLevel3Included() { + public void testListChildLevel3Included() throws TransformationException { Consumer<AbstractT> addBee = t -> t.addBee(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(addBee), createT2(addBee), createT3(addBee)); Assertions.assertEquals(T3_NAME + B_NAME, root.getT3().getBee(0).getName()); @@ -131,7 +132,7 @@ public class TestTypeLevel4 { } @Test - public void testListChildLevel4SomeExcluded() { + public void testListChildLevel4SomeExcluded() throws TransformationException { Consumer<AbstractT> addBee = t -> t.addBee(createB(t.getName() + B_NAME)); TRoot root = createTRoot(createA(A_NAME), createT1(addBee), createT2(addBee), createT3(addBee)); Assertions.assertEquals(T3_NAME + B_NAME, root.getT3().getBee(0).getName()); @@ -149,7 +150,7 @@ public class TestTypeLevel4 { } @Test - public void testRelationLevel3Included() { + public void testRelationLevel3Included() throws TransformationException { final A a = createA(A_NAME); Consumer<AbstractT> setOneA = t -> t.setOneA(a); TRoot root = createTRoot(a, createT1(setOneA), createT2(setOneA), createT3(setOneA)); @@ -166,7 +167,7 @@ public class TestTypeLevel4 { } @Test - public void testRelationLevel4SomeExcluded() { + public void testRelationLevel4SomeExcluded() throws TransformationException { final A a = createA(A_NAME); Consumer<AbstractT> setOneA = t -> t.setOneA(a); TRoot root = createTRoot(a, createT1(setOneA), createT2(setOneA), createT3(setOneA)); @@ -185,7 +186,7 @@ public class TestTypeLevel4 { } @Test - public void testAttributeLevel3Excluded() { + public void testAttributeLevel3Excluded() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = TestUtils.dumpModel(root, @@ -200,7 +201,7 @@ public class TestTypeLevel4 { } @Test - public void testAttributeLevel4SomeIncluded() { + public void testAttributeLevel4SomeIncluded() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = TestUtils.dumpModel(root, @@ -217,7 +218,7 @@ public class TestTypeLevel4 { } @Test - public void testNTALevel3Excluded() { + public void testNTALevel3Excluded() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = TestUtils.dumpModel(root, @@ -229,7 +230,7 @@ public class TestTypeLevel4 { } @Test - public void testNTALevel4SomeIncluded() { + public void testNTALevel4SomeIncluded() throws TransformationException { TRoot root = createTRoot(createA(A_NAME), createT1(), createT2(), createT3()); List<DumpNode> nodes = TestUtils.dumpModel(root, diff --git a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java index 9d76fca579ef4856ee7279949de341c7a48a4afc..70213c50de832d945eca1cb8afa891656fc78896 100644 --- a/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java +++ b/dumpAst.tests/src/test/java/de/tudresden/inf/st/jastadd/testDumper/TestUtils.java @@ -150,11 +150,11 @@ public class TestUtils { return Assertions.assertThat(map.get(key)).flatExtracting(NAME_EXTRACTOR); } - public static List<DumpNode> dumpModel(Object target) { + public static List<DumpNode> dumpModel(Object target) throws TransformationException { return dumpModel(target, db -> {}); } - public static List<DumpNode> dumpModel(Object target, Consumer<DumpBuilder> options) { + public static List<DumpNode> dumpModel(Object target, Consumer<DumpBuilder> options) throws TransformationException { ExposingDumpBuilder builder = new ExposingDumpBuilder(target); builder.excludeNullNodes(); options.accept(builder); @@ -297,7 +297,7 @@ public class TestUtils { } @Override - public DumpAst build() { + public DumpAst build() throws TransformationException { return super.build(); } }