Skip to content

Commit

Permalink
test(SniperJavaPrettyPrinter): add javax related error (issue INRIA#3321
Browse files Browse the repository at this point in the history
  • Loading branch information
gibahjoe authored Apr 30, 2020
1 parent dd31165 commit 4bc09ac
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@
<artifactId>maven-invoker</artifactId>
<version>3.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/spoon/test/issue3321/CtClassProcessor.java
Original file line number Diff line number Diff line change
@@ -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<CtClass> {
@Override
public void process(CtClass element) {

}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
9 changes: 9 additions & 0 deletions src/test/java/spoon/test/issue3321/SomeObjectDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package spoon.test.issue3321;

/**
* @author Gibah Joseph
* Email: gibahjoe@gmail.com
* Apr, 2020
**/
public class SomeObjectDto {
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Empty file.

0 comments on commit 4bc09ac

Please sign in to comment.