diff --git a/torch-compiler/src/test/java/org/brightify/torch/SimpleEntityTest.java b/torch-compiler/src/test/java/org/brightify/torch/SimpleEntityTest.java index 2f9f2c4..8da488d 100644 --- a/torch-compiler/src/test/java/org/brightify/torch/SimpleEntityTest.java +++ b/torch-compiler/src/test/java/org/brightify/torch/SimpleEntityTest.java @@ -65,5 +65,43 @@ public void testEntityWithTwoIdProperties() { .withErrorContaining("There has to be exactly one @Id property in each entity!") .in(JavaFileObjects.forResource("negative/EntityWithTwoIdProperties.java")).onLine(13); } + + @Test + public void testEntityWithIntId(){ + ASSERT.about(javaSource()).that(JavaFileObjects.forResource("negative/EntityWithIntId.java")). + processedWith(new TorchCompilerEntrypoint()).failsToCompile(). + withErrorContaining("@Id property has to be type Long."). + in(JavaFileObjects.forResource("negative/EntityWithIntId.java")).onLine(9); + } + + @Test + public void testEntityWithPrimitiveIntId(){ + ASSERT.about(javaSource()).that(JavaFileObjects.forResource("negative/EntityWithPrimitiveIntId.java")). + processedWith(new TorchCompilerEntrypoint()).failsToCompile(). + withErrorContaining("@Id property has to be type Long."). + in(JavaFileObjects.forResource("negative/EntityWithPrimitiveIntId.java")).onLine(9); + } + + @Test + public void testEntityWithLongFieldsWithoutIdAnnotation(){ + ASSERT.about(javaSource()).that(JavaFileObjects.forResource("negative/EntityWithLongFieldsWithoutIdAnnotation.java")). + processedWith(new TorchCompilerEntrypoint()).failsToCompile(). + withErrorContaining("There has to be exactly one @Id property in each entity!"). + in(JavaFileObjects.forResource("negative/EntityWithLongFieldsWithoutIdAnnotation.java")).onLine(6); + + } + + @Test + public void testClassWithoutEntityAnnotation(){ + ASSERT.about(javaSource()).that(JavaFileObjects.forResource("negative/ClassWithoutEntityAnnotation.java")). + processedWith(new TorchCompilerEntrypoint()).compilesWithoutError(); + } + + @Test + public void testClassWithNoAnnotations(){ + ASSERT.about(javaSource()).that(JavaFileObjects.forResource("negative/ClassWithNoAnnotations.java")). + processedWith(new TorchCompilerEntrypoint()).compilesWithoutError(); + + } } diff --git a/torch-compiler/src/test/resources/negative/ClassWithNoAnnotations.java b/torch-compiler/src/test/resources/negative/ClassWithNoAnnotations.java new file mode 100644 index 0000000..f7c6214 --- /dev/null +++ b/torch-compiler/src/test/resources/negative/ClassWithNoAnnotations.java @@ -0,0 +1,7 @@ +package negative; + +public class ClassWithNoAnnotations{ + Long id; + String name; + Long accountNumber; +} \ No newline at end of file diff --git a/torch-compiler/src/test/resources/negative/ClassWithoutEntityAnnotation.java b/torch-compiler/src/test/resources/negative/ClassWithoutEntityAnnotation.java new file mode 100644 index 0000000..9ed37f8 --- /dev/null +++ b/torch-compiler/src/test/resources/negative/ClassWithoutEntityAnnotation.java @@ -0,0 +1,9 @@ +package negative; + +import org.brightify.torch.annotation.Id; + +public class ClassWithoutEntityAnnotation{ + @Id + Long id; + +} \ No newline at end of file diff --git a/torch-compiler/src/test/resources/negative/EntityWithIntId.java b/torch-compiler/src/test/resources/negative/EntityWithIntId.java new file mode 100644 index 0000000..afbe2d6 --- /dev/null +++ b/torch-compiler/src/test/resources/negative/EntityWithIntId.java @@ -0,0 +1,10 @@ +package negative; + +import org.brightify.torch.annotation.Entity; +import org.brightify.torch.annotation.Id; + +@Entity +public class EntityWithIntId { + @Id + Integer id; +} \ No newline at end of file diff --git a/torch-compiler/src/test/resources/negative/EntityWithLongFieldsWithoutIdAnnotation.java b/torch-compiler/src/test/resources/negative/EntityWithLongFieldsWithoutIdAnnotation.java new file mode 100644 index 0000000..ce4a363 --- /dev/null +++ b/torch-compiler/src/test/resources/negative/EntityWithLongFieldsWithoutIdAnnotation.java @@ -0,0 +1,10 @@ +package negative; + +import org.brightify.torch.annotation.Entity; + +@Entity +public class EntityWithLongFieldsWithoutIdAnnotation{ + Long id1; + Long id2; + Long id3; +} \ No newline at end of file diff --git a/torch-compiler/src/test/resources/negative/EntityWithPrimitiveIntId.java b/torch-compiler/src/test/resources/negative/EntityWithPrimitiveIntId.java new file mode 100644 index 0000000..dcc9eb4 --- /dev/null +++ b/torch-compiler/src/test/resources/negative/EntityWithPrimitiveIntId.java @@ -0,0 +1,10 @@ +package negative; + +import org.brightify.torch.annotation.Id; +import org.brightify.torch.annotation.Entity; + +@Entity +public class EntityWithPrimitiveIntId { + @Id + int id; +} \ No newline at end of file