37 lines
1.1 KiB
Java
37 lines
1.1 KiB
Java
package jef.model;
|
|
|
|
import jef.DbSet;
|
|
import jef.model.annotations.Clazz;
|
|
import jef.model.annotations.Id;
|
|
import jef.serializable.SerializableObject;
|
|
import lombok.Getter;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
class ModelBuilderSimpleTest {
|
|
@Test
|
|
public void testClone() {
|
|
var mb = ModelBuilder.from(Ctx.class);
|
|
|
|
assertEquals(1, mb.getEntities().size());
|
|
assertEquals("objects1", mb.getEntity(TestClass.class).getName());
|
|
assertTrue(mb.getEntity(TestClass.class).getFields().stream().allMatch(e -> e.getEntity() == mb.getEntity(TestClass.class)));
|
|
}
|
|
|
|
public static class Ctx extends DbContext {
|
|
@Clazz(TestClass.class)
|
|
private DbSet<TestClass> objects1;
|
|
}
|
|
|
|
@Getter
|
|
public static class TestClass extends SerializableObject {
|
|
@Id
|
|
public int i = 1;
|
|
public Object o = new Object();
|
|
public double d;
|
|
public float f;
|
|
public long l;
|
|
}
|
|
} |