Search in sources :

Example 1 with MeaningfulFK

use of org.apache.cayenne.testdo.relationships.MeaningfulFK in project cayenne by apache.

the class MeaningfulFKIT method testValidateForSave1.

@Test
public void testValidateForSave1() throws Exception {
    MeaningfulFK testObject = context.newObject(MeaningfulFK.class);
    ValidationResult validation = new ValidationResult();
    testObject.validateForSave(validation);
    assertTrue("Must fail validation due to missing required relationship", validation.hasFailures());
    assertEquals("Must fail validation due to missing required relationship", 1, validation.getFailures().size());
}
Also used : MeaningfulFK(org.apache.cayenne.testdo.relationships.MeaningfulFK) ValidationResult(org.apache.cayenne.validation.ValidationResult) Test(org.junit.Test)

Example 2 with MeaningfulFK

use of org.apache.cayenne.testdo.relationships.MeaningfulFK in project cayenne by apache.

the class MeaningfulFKIT method testValidateForSave2.

@Test
public void testValidateForSave2() throws Exception {
    MeaningfulFK testObject = context.newObject(MeaningfulFK.class);
    RelationshipHelper related = testObject.getObjectContext().newObject(RelationshipHelper.class);
    testObject.setToRelationshipHelper(related);
    ValidationResult validation = new ValidationResult();
    testObject.validateForSave(validation);
    assertFalse(validation.hasFailures());
}
Also used : MeaningfulFK(org.apache.cayenne.testdo.relationships.MeaningfulFK) RelationshipHelper(org.apache.cayenne.testdo.relationships.RelationshipHelper) ValidationResult(org.apache.cayenne.validation.ValidationResult) Test(org.junit.Test)

Aggregations

MeaningfulFK (org.apache.cayenne.testdo.relationships.MeaningfulFK)2 ValidationResult (org.apache.cayenne.validation.ValidationResult)2 Test (org.junit.Test)2 RelationshipHelper (org.apache.cayenne.testdo.relationships.RelationshipHelper)1