86 lines
2.1 KiB
Java
86 lines
2.1 KiB
Java
package org.warp.jcwdb.tests;
|
|
|
|
import org.junit.After;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.warp.jcwdb.ann.*;
|
|
import org.warp.jcwdb.utils.TestUtils;
|
|
|
|
import java.io.IOException;
|
|
|
|
public class DBMultipleDBObjects {
|
|
private TestUtils.WrappedDb db;
|
|
private RootTwoClasses root;
|
|
|
|
@Before
|
|
public void setUp() throws Exception {
|
|
db = TestUtils.wrapDb().create((db) -> {
|
|
root = db.get().loadRoot(RootTwoClasses.class);
|
|
});
|
|
root.class1 = new TestUtils.RootClass(db.get());
|
|
db.setRootClassValues(root.class1);
|
|
root.class2 = new TestUtils.RootClass(db.get());
|
|
db.setRootClassValues(root.class2);
|
|
root.setClass3(new TestUtils.RootClass(db.get()));
|
|
db.setRootClassValues(root.getClass3());
|
|
root.setClass4(new TestUtils.RootClass(db.get()));
|
|
db.setRootClassValues(root.getClass4());
|
|
db.closeAndReopen();
|
|
}
|
|
|
|
@Test
|
|
public void shouldMatchMultipleObjects() {
|
|
db.testRootClassValues(root.class1);
|
|
db.testRootClassValues(root.class2);
|
|
db.testRootClassValues(root.getClass3());
|
|
db.testRootClassValues(root.getClass4());
|
|
}
|
|
|
|
@After
|
|
public void tearDown() throws Exception {
|
|
db.delete();
|
|
}
|
|
|
|
public static class RootTwoClasses extends DBObject {
|
|
|
|
@DBField(id = 0, type = DBDataType.DATABASE_OBJECT)
|
|
public TestUtils.RootClass class1;
|
|
|
|
@DBField(id = 1, type = DBDataType.DATABASE_OBJECT)
|
|
public TestUtils.RootClass class2;
|
|
|
|
public RootTwoClasses() {
|
|
super();
|
|
}
|
|
|
|
public RootTwoClasses(JCWDatabase database) throws IOException {
|
|
super(database);
|
|
}
|
|
|
|
@DBPropertyGetter(id = 0, type = DBDataType.DATABASE_OBJECT)
|
|
public TestUtils.RootClass getClass3() {
|
|
return getProperty();
|
|
}
|
|
|
|
@DBPropertySetter(id = 0, type = DBDataType.DATABASE_OBJECT)
|
|
public void setClass3(TestUtils.RootClass value) {
|
|
setProperty(value);
|
|
}
|
|
|
|
@DBPropertyGetter(id = 1, type = DBDataType.DATABASE_OBJECT)
|
|
public TestUtils.RootClass getClass4() {
|
|
return getProperty();
|
|
}
|
|
|
|
@DBPropertySetter(id = 1, type = DBDataType.DATABASE_OBJECT)
|
|
public void setClass4(TestUtils.RootClass value) {
|
|
setProperty(value);
|
|
}
|
|
|
|
@Override
|
|
public void initialize() throws IOException {
|
|
|
|
}
|
|
}
|
|
}
|