use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypeWithEnumTestSuite method verifyDefaultValuesFromDescriptor.
@Test
public void verifyDefaultValuesFromDescriptor() throws Exception {
DynamicType simpleType = dynamicHelper.getType("Simple");
assertNotNull(simpleType);
DynamicEntity simpleInstance = (DynamicEntity) simpleType.getDescriptor().getObjectBuilder().buildNewInstance();
assertDefaultValues(simpleInstance);
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_AggregateObject method verifyChangTracking.
@Test
public void verifyChangTracking() {
persistSimpleA();
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
Assert.assertNotNull(simpleTypeA);
UnitOfWork uow = session.acquireUnitOfWork();
ReadObjectQuery roq = dynamicHelper.newReadObjectQuery("SimpleA");
roq.setSelectionCriteria(roq.getExpressionBuilder().get("id").equal(1));
DynamicEntityImpl sharedA = (DynamicEntityImpl) session.executeQuery(roq);
assertNotNull(sharedA);
assertNull(sharedA._persistence_getPropertyChangeListener());
DynamicEntityImpl a = (DynamicEntityImpl) uow.executeQuery(roq);
assertNotNull(a);
assertNotNull(a._persistence_getPropertyChangeListener());
DynamicEntityImpl c = a.<DynamicEntityImpl>get("c");
assertNotNull(c);
assertNotNull(c._persistence_getPropertyChangeListener());
assertTrue(c._persistence_getPropertyChangeListener() instanceof AggregateAttributeChangeListener);
uow.release();
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_AggregateObject method createSimpleA.
@Test
public void createSimpleA() {
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
Assert.assertNotNull(simpleTypeA);
DynamicEntity a = simpleTypeA.newDynamicEntity();
assertNotNull(a);
assertEquals(((Number) a.get("id")).intValue(), 0);
assertFalse(a.isSet("id"));
assertFalse(a.isSet("value1"));
assertFalse(a.isSet("b"));
DynamicType typeC = dynamicHelper.getType("SimpleC");
assertEquals(a.get("c").getClass(), typeC.newDynamicEntity().getClass());
DynamicEntity c = a.get("c");
assertNotNull(c);
assertEquals(((Number) c.get("value4")).doubleValue(), 0.0, 0.01);
assertFalse(c.isSet("value5"));
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_AggregateObject method persistSimpleA.
@Test
public void persistSimpleA() {
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
Assert.assertNotNull(simpleTypeA);
DynamicEntity simpleInstance = simpleTypeA.newDynamicEntity();
simpleInstance.set("id", 1);
simpleInstance.set("value1", "A1");
UnitOfWork uow = session.acquireUnitOfWork();
uow.registerNewObject(simpleInstance);
uow.commit();
ReportQuery countQuery = dynamicHelper.newReportQuery("SimpleA", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
int simpleCount = ((Number) session.executeQuery(countQuery)).intValue();
Assert.assertEquals(1, simpleCount);
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class ComicsPopulateAndQueryTestSuite method loadPublishers.
protected Map<Integer, DynamicEntity> loadPublishers(Session server, URL fileURL) {
DynamicType type = dynamicHelper.getType("Publisher");
Map<Integer, DynamicEntity> publishers = new HashMap<Integer, DynamicEntity>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(fileURL.openStream()));
String nextLine = null;
while ((nextLine = reader.readLine()) != null) {
DynamicEntity publisher = buildPublisher(type, nextLine);
publishers.put(publisher.<Integer>get("id"), publisher);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// ignoree
}
}
}
return publishers;
}
Aggregations