use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_OneToMany method createSimpleA.
@Test
public void createSimpleA() {
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
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();
assertEquals(1, simpleCount);
session.release();
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypeTestSuite 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 SimpleTypeWithEnumTestSuite method verifyDefaultValuesFromEntityType.
@Test
public void verifyDefaultValuesFromEntityType() throws Exception {
DynamicType type = dynamicHelper.getType("Simple");
assertNotNull(type);
DynamicEntity simpleInstance = type.newDynamicEntity();
assertDefaultValues(simpleInstance);
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypeWithEnumTestSuite method createSimpleInstance.
public DynamicEntity createSimpleInstance(Session session, int id) {
DynamicType simpleEntityType = dynamicHelper.getType("Simple");
Assert.assertNotNull(simpleEntityType);
DynamicEntity simpleInstance = simpleEntityType.newDynamicEntity();
simpleInstance.set("id", id);
simpleInstance.set("value2", true);
Enum blue = Enum.valueOf(simpleEnum.getClass(), "BLUE");
simpleInstance.set("color", blue);
ReportQuery countQuery = dynamicHelper.newReportQuery("Simple", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
assertEquals(0, ((Number) session.executeQuery(countQuery)).intValue());
UnitOfWork uow = session.acquireUnitOfWork();
uow.registerNewObject(simpleInstance);
uow.commit();
assertEquals(1, ((Number) session.executeQuery(countQuery)).intValue());
DynamicEntity foundEntity = find(dynamicHelper, session, 1);
assertNotNull(foundEntity);
assertEquals(simpleInstance.<Integer>get("id"), foundEntity.<Integer>get("id"));
assertEquals(simpleInstance.<String>get("value1"), foundEntity.<String>get("value1"));
assertEquals(simpleInstance.<Boolean>get("value2"), foundEntity.<Boolean>get("value2"));
assertSame(simpleInstance.<Enum>get("color"), foundEntity.<Enum>get("color"));
session.release();
return simpleInstance;
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypeWithEnumTestSuite method invalidDirectMappingSet_id.
@Test(expected = DynamicException.class)
public void invalidDirectMappingSet_id() throws Exception {
DynamicType type = dynamicHelper.getType("Simple");
DynamicEntity entity = type.newDynamicEntity();
entity.set("id", 1l);
}
Aggregations