From 4bc09acc561cca956da14bb02fbe92ce91802411 Mon Sep 17 00:00:00 2001 From: gibahjoe Date: Thu, 30 Apr 2020 13:19:36 +0100 Subject: [PATCH] test(SniperJavaPrettyPrinter): add javax related error (issue #3321) (#3324) --- pom.xml | 8 ++++ .../test/issue3321/CtClassProcessor.java | 16 ++++++++ .../SniperPrettyPrinterJavaxTest.java | 31 +++++++++++++++ .../spoon/test/issue3321/SomeObjectDto.java | 9 +++++ .../source/JavaxImportTestSource.java | 39 +++++++++++++++++++ .../source/JavaxImportTestSource.java | 0 6 files changed, 103 insertions(+) create mode 100644 src/test/java/spoon/test/issue3321/CtClassProcessor.java create mode 100644 src/test/java/spoon/test/issue3321/SniperPrettyPrinterJavaxTest.java create mode 100644 src/test/java/spoon/test/issue3321/SomeObjectDto.java create mode 100644 src/test/java/spoon/test/issue3321/source/JavaxImportTestSource.java create mode 100644 src/test/resources/spoon/test/issue3321/source/JavaxImportTestSource.java diff --git a/pom.xml b/pom.xml index 759ad952855..ec3cb1d2444 100644 --- a/pom.xml +++ b/pom.xml @@ -159,6 +159,14 @@ maven-invoker 3.0.1 + + + javax.validation + validation-api + 2.0.1.Final + test + + com.google.code.gson gson diff --git a/src/test/java/spoon/test/issue3321/CtClassProcessor.java b/src/test/java/spoon/test/issue3321/CtClassProcessor.java new file mode 100644 index 00000000000..bded288c54c --- /dev/null +++ b/src/test/java/spoon/test/issue3321/CtClassProcessor.java @@ -0,0 +1,16 @@ +package spoon.test.issue3321; + +import spoon.processing.AbstractProcessor; +import spoon.reflect.declaration.CtClass; + +/** + * @author Gibah Joseph + * Email: gibahjoe@gmail.com + * Apr, 2020 + **/ +public class CtClassProcessor extends AbstractProcessor { + @Override + public void process(CtClass element) { + + } +} diff --git a/src/test/java/spoon/test/issue3321/SniperPrettyPrinterJavaxTest.java b/src/test/java/spoon/test/issue3321/SniperPrettyPrinterJavaxTest.java new file mode 100644 index 00000000000..840af083c22 --- /dev/null +++ b/src/test/java/spoon/test/issue3321/SniperPrettyPrinterJavaxTest.java @@ -0,0 +1,31 @@ +package spoon.test.issue3321; + +import org.junit.Test; +import org.junit.Ignore; +import spoon.Launcher; +import spoon.compiler.Environment; +import spoon.support.sniper.SniperJavaPrettyPrinter; +import spoon.test.GitHubIssue; + +/** + * @author Gibah Joseph + * Email: gibahjoe@gmail.com + * Apr, 2020 + **/ +public class SniperPrettyPrinterJavaxTest { + @Test + @GitHubIssue(issueNumber = 3321) + @Ignore("UnresolvedBug") + public void testThatCanGenerateSniperPrettyPrintedSourceForJavaxAnnotatedClasses() { + final Launcher l = new Launcher(); + Environment e = l.getEnvironment(); + + e.setPrettyPrinterCreator(() -> new SniperJavaPrettyPrinter(e)); + e.setNoClasspath(true); + e.setAutoImports(true); + l.addProcessor(new CtClassProcessor()); + l.addInputResource("src/test/java/spoon/test/issue3321/source/JavaxImportTestSource.java"); + l.setSourceOutputDirectory("src/test/resources"); + l.run(); + } +} diff --git a/src/test/java/spoon/test/issue3321/SomeObjectDto.java b/src/test/java/spoon/test/issue3321/SomeObjectDto.java new file mode 100644 index 00000000000..c26c09f316f --- /dev/null +++ b/src/test/java/spoon/test/issue3321/SomeObjectDto.java @@ -0,0 +1,9 @@ +package spoon.test.issue3321; + +/** + * @author Gibah Joseph + * Email: gibahjoe@gmail.com + * Apr, 2020 + **/ +public class SomeObjectDto { +} diff --git a/src/test/java/spoon/test/issue3321/source/JavaxImportTestSource.java b/src/test/java/spoon/test/issue3321/source/JavaxImportTestSource.java new file mode 100644 index 00000000000..a9f9f0b8700 --- /dev/null +++ b/src/test/java/spoon/test/issue3321/source/JavaxImportTestSource.java @@ -0,0 +1,39 @@ +package spoon.test.issue3321.source; + +import spoon.test.issue3321.SomeObjectDto; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +/** + * @author Gibah Joseph + * Email: gibahjoe@gmail.com + * Apr, 2020 + **/ +public class JavaxImportTestSource { + private String firstName; + private String lastName; + + public String getFirstName() { + return firstName; + } + + public JavaxImportTestSource setObject(@NotNull @Valid SomeObjectDto someObjectDto) { + + return this; + } + + public JavaxImportTestSource setFirstName(@NotNull @Valid String firstName) { + this.firstName = firstName; + return this; + } + + public String getLastName() { + return lastName; + } + + public JavaxImportTestSource setLastName(String lastName) { + this.lastName = lastName; + return this; + } +} diff --git a/src/test/resources/spoon/test/issue3321/source/JavaxImportTestSource.java b/src/test/resources/spoon/test/issue3321/source/JavaxImportTestSource.java new file mode 100644 index 00000000000..e69de29bb2d