use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest5 in project cayenne by apache.
the class FlattenedRelationshipsIT method testNullFlattenedComplexToOneRelationship.
/**
* Should be able to save/insert an object with null flattened (complex) toOne relationship
* @throws Exception
*/
@Test
public void testNullFlattenedComplexToOneRelationship() throws Exception {
FlattenedTest5 ft5 = context.newObject(FlattenedTest5.class);
ft5.setName("FT5");
// should be valid for save
ValidationResult validationResult = new ValidationResult();
ft5.validateForSave(validationResult);
assertTrue(validationResult.toString(), validationResult.getFailures().isEmpty());
context.commitChanges();
assertEquals(1, ObjectSelect.query(FlattenedTest5.class).selectCount(context));
}
use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest5 in project cayenne by apache.
the class FlattenedRelationshipsIT method testFlattenedComplexToOneRelationship.
/**
* Should be able to save/insert an object with flattened (complex) toOne relationship
* @throws Exception
*/
@Test
public void testFlattenedComplexToOneRelationship() throws Exception {
FlattenedTest1 ft1 = context.newObject(FlattenedTest1.class);
ft1.setName("FT1");
FlattenedTest5 ft5 = context.newObject(FlattenedTest5.class);
ft5.setName("FT5");
ft5.setToFT1(ft1);
context.commitChanges();
FlattenedTest5 ft5Persisted = ObjectSelect.query(FlattenedTest5.class).selectFirst(context);
assertEquals(ft1, ft5Persisted.getToFT1());
}
Aggregations