Files
JEF/src/test/java/jef/model/EntityDefaultConstructorCheckerTest.java
2022-11-23 13:50:54 +01:00

39 lines
1.2 KiB
Java

package jef.model;
import jef.model.annotations.Id;
import jef.serializable.SerializableObject;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
class EntityDefaultConstructorCheckerTest {
@Test
public void test0ArgConstructor() {
var mb = new ModelBuilder();
EntityDefaultConstructorChecker.checkEntity(mb.entity(TestClass0Arg.class));
assertTrue(true);
}
@Test
public void testNon0ArgConstructor() {
var mb = new ModelBuilder();
var ex = assertThrows(ModelException.class, () -> EntityDefaultConstructorChecker.checkEntity(mb.entity(TestClassNon0Arg.class)));
assertEquals("Class 'TestClassNon0Arg' does not have a default constructor!", ex.getMessage());
}
@NoArgsConstructor
public static class TestClass0Arg extends SerializableObject {
@Id
public int i = 1;
}
@AllArgsConstructor
public static class TestClassNon0Arg extends SerializableObject {
@Id
public int i = 1;
}
}