use of jakarta.annotation.Generated in project eclipselink by eclipse-ee4j.
the class TestProcessor method testGenerate.
private void testGenerate(String name, String pxml, String oxml) throws Exception {
TestFO entity = new TestFO("org.Sample", "package org; import jakarta.persistence.Entity; @Entity public class Sample { public Sample() {} public int getX() {return 1;} interface A {}}");
Result result = runProject(name, getJavacOptions("-A" + CanonicalModelProperties.CANONICAL_MODEL_GENERATE_GENERATED + "=false", "-Aeclipselink.logging.level.processor=OFF"), Arrays.asList(entity), pxml, oxml);
File outputFile = new File(result.srcOut, "org/Sample_.java");
Assert.assertTrue("Model file not generated", outputFile.exists());
Assert.assertTrue(Files.lines(outputFile.toPath()).noneMatch(s -> s.contains("Generated")));
Assert.assertTrue("Compilation failed", result.success);
}
use of jakarta.annotation.Generated in project eclipselink by eclipse-ee4j.
the class TestProcessor method testGenerateComment.
private void testGenerateComment(String name, String pxml, String oxml) throws Exception {
TestFO entity = new TestFO("org.Sample", "package org; import jakarta.persistence.Entity; @Entity public class Sample { public Sample() {} public int getX() {return 1;} interface A {}}");
Result result = runProject(name, getJavacOptions("-A" + CanonicalModelProperties.CANONICAL_MODEL_GENERATE_COMMENTS + "=false", "-Aeclipselink.logging.level.processor=OFF"), Arrays.asList(entity), pxml, oxml);
File outputFile = new File(result.srcOut, "org/Sample_.java");
Assert.assertTrue("Model file not generated", outputFile.exists());
Assert.assertTrue(Files.lines(outputFile.toPath()).noneMatch(s -> s.contains("comments=")));
Assert.assertTrue("Compilation failed", result.success);
}
use of jakarta.annotation.Generated in project eclipselink by eclipse-ee4j.
the class TestProcessor method testProc.
private void testProc(String name, String pxml, String oxml) throws Exception {
TestFO entity = new TestFO("org.Sample", "package org; import jakarta.persistence.Entity; @Entity public class Sample { public Sample() {} public int getX() {return 1;} interface A {}}");
TestFO nonSC = new TestFO("some.IF", "package some; public class IF { public IF() {}}");
TestFO nonAnn = new TestFO("custom.Ann", "package custom; public @interface Ann { }");
TestFO nonExt = new TestFO("external.Cls", "package external; public class Cls { public Cls(){}}");
TestFO nonEntity = new TestFO("org.NotE", "package org; import jakarta.persistence.Entity; public class NotE extends some.IF { public NotE() {} @custom.Ann public external.Cls getW() {return new Object();}}");
TestFO generated8 = new TestFO("org.Gen8", "package org; import jakarta.annotation.Generated; @Generated(\"com.example.Generator\") public class Gen8 { public Gen8() {} public int getY() {return 42;}}");
TestFO generated9 = new TestFO("org.Gen9", "package org; @javax.annotation.processing.Generated(\"com.example.Generator\") public class Gen9 { public Gen9() {} public int getZ() {return 9*42;}}");
Result result = runProject(name, getJavacOptions("-Aeclipselink.logging.level.processor=OFF"), Arrays.asList(entity, nonSC, nonAnn, nonExt, nonEntity, generated8, generated9), pxml, oxml);
File outputFile = new File(result.srcOut, "org/Sample_.java");
Assert.assertTrue("Model file not generated", outputFile.exists());
Assert.assertTrue(Files.lines(outputFile.toPath()).anyMatch(s -> s.contains("@StaticMetamodel(Sample.class)")));
}
use of jakarta.annotation.Generated in project eclipselink by eclipse-ee4j.
the class TestProcessor method testTypeUse.
public void testTypeUse(String name, String pxml, String oxml) throws Exception {
TestFO entity = new TestFO("org.Ent", "package org; @jakarta.persistence.Entity public class Ent { @org.ann.NotNull private byte[] bytes;}");
TestFO ann = new TestFO("org.ann.NotNull", "package org.ann; @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE) public @interface NotNull {}");
Result result = runProject(name, getJavacOptions("-Aeclipselink.logging.level.processor=OFF"), Arrays.asList(entity, ann), pxml, oxml);
File outputFile = new File(result.srcOut, "org/Ent_.java");
Assert.assertTrue("Model file not generated", outputFile.exists());
Assert.assertTrue(Files.lines(outputFile.toPath()).noneMatch(s -> s.contains("NotNull")));
Assert.assertTrue("Compilation failed", result.success);
}
Aggregations