Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests to check Int/int id and missing annotations #49

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package negative;

public class ClassWithNoAnnotations{
Long id;
String name;
Long accountNumber;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package negative;

import org.brightify.torch.annotation.Id;

public class ClassWithoutEntityAnnotation{
@Id
Long id;

}
10 changes: 10 additions & 0 deletions torch-compiler/src/test/resources/negative/EntityWithIntId.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package negative;

import org.brightify.torch.annotation.Entity;

@Entity
public class EntityWithLongFieldsWithoutIdAnnotation{
Long id1;
Long id2;
Long id3;
}
Original file line number Diff line number Diff line change
@@ -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;
}