use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest3 in project cayenne by apache.
the class FlattenedArcKeyIT method testHashCode.
@Test
public void testHashCode() {
ObjectId src = new ObjectId("X");
ObjectId target = new ObjectId("Y");
ObjRelationship r1 = entityResolver.getObjEntity(FlattenedTest3.class).getRelationship(FlattenedTest3.TO_FT1.getName());
FlattenedArcKey update = new FlattenedArcKey(src, target, r1);
FlattenedArcKey update1 = new FlattenedArcKey(target, src, r1.getReverseRelationship());
ObjRelationship r3 = entityResolver.getObjEntity(FlattenedTest1.class).getRelationship(FlattenedTest1.FT3OVER_COMPLEX.getName());
FlattenedArcKey update2 = new FlattenedArcKey(target, src, r3);
int h = update.hashCode();
int h1 = update1.hashCode();
int h2 = update2.hashCode();
assertTrue(h == h1);
assertTrue(h == update.hashCode());
assertFalse(h == h2);
}
use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest3 in project cayenne by apache.
the class FlattenedRelationshipInContextIT method testIsToOneTargetModifiedFlattenedFault1.
@Test
public void testIsToOneTargetModifiedFlattenedFault1() throws Exception {
createFlattenedTestDataSet();
// fetch
List<?> ft3s = context.performQuery(new SelectQuery(FlattenedTest3.class));
assertEquals(1, ft3s.size());
FlattenedTest3 ft3 = (FlattenedTest3) ft3s.get(0);
// mark as dirty for the purpose of the test...
ft3.setPersistenceState(PersistenceState.MODIFIED);
assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
// test that checking for modifications does not trigger a fault, and generally
// works well
ClassDescriptor d = context.getEntityResolver().getClassDescriptor("FlattenedTest3");
ArcProperty flattenedRel = (ArcProperty) d.getProperty("toFT1");
ObjectDiff diff = context.getObjectStore().registerDiff(ft3.getObjectId(), null);
assertFalse(DataRowUtils.isToOneTargetModified(flattenedRel, ft3, diff));
assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
}
use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest3 in project cayenne by apache.
the class FlattenedRelationshipsIT method testRefetchWithFlattenedFaultToOneTarget1.
@Test
public void testRefetchWithFlattenedFaultToOneTarget1() throws Exception {
createFlattenedTestDataSet();
// fetch
List<?> ft3s = context.performQuery(new SelectQuery(FlattenedTest3.class));
assertEquals(1, ft3s.size());
FlattenedTest3 ft3 = (FlattenedTest3) ft3s.get(0);
assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
// refetch
context.performQuery(new SelectQuery(FlattenedTest3.class));
assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);
}
use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest3 in project cayenne by apache.
the class FlattenedRelationshipsIT method testInsertJoinWithPK.
@Test
public void testInsertJoinWithPK() throws Exception {
FlattenedTest1 obj01 = context.newObject(FlattenedTest1.class);
FlattenedTest3 obj11 = context.newObject(FlattenedTest3.class);
FlattenedTest3 obj12 = context.newObject(FlattenedTest3.class);
obj01.setName("t01");
obj11.setName("t11");
obj12.setName("t12");
obj01.addToFt3OverComplex(obj11);
obj01.addToFt3OverComplex(obj12);
context.commitChanges();
int pk = Cayenne.intPKForObject(obj01);
context.invalidateObjects(obj01, obj11, obj12);
FlattenedTest1 fresh01 = Cayenne.objectForPK(context1, FlattenedTest1.class, pk);
assertEquals("t01", fresh01.getName());
ValueHolder related = (ValueHolder) fresh01.getFt3OverComplex();
assertTrue(related.isFault());
assertEquals(2, ((List<?>) related).size());
}
use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest3 in project cayenne by apache.
the class FlattenedRelationshipsIT method testToOneSeriesFlattenedRel.
@Test
public void testToOneSeriesFlattenedRel() {
FlattenedTest1 ft1 = (FlattenedTest1) context.newObject("FlattenedTest1");
ft1.setName("FT1Name");
FlattenedTest2 ft2 = (FlattenedTest2) context.newObject("FlattenedTest2");
ft2.setName("FT2Name");
FlattenedTest3 ft3 = (FlattenedTest3) context.newObject("FlattenedTest3");
ft3.setName("FT3Name");
ft2.setToFT1(ft1);
ft2.addToFt3Array(ft3);
context.commitChanges();
context.invalidateObjects(ft1, ft2, ft3);
SelectQuery q = new SelectQuery(FlattenedTest3.class);
q.setQualifier(ExpressionFactory.matchExp("name", "FT3Name"));
List<?> results = context1.performQuery(q);
assertEquals(1, results.size());
FlattenedTest3 fetchedFT3 = (FlattenedTest3) results.get(0);
FlattenedTest1 fetchedFT1 = fetchedFT3.getToFT1();
assertEquals("FT1Name", fetchedFT1.getName());
}
Aggregations