use of org.apache.cayenne.util.PersistentObjectList in project cayenne by apache.
the class ProtostuffPersistentObjectCollectionsTest method testPersistentObjectList.
@Test
public void testPersistentObjectList() throws IOException {
PersistentObjectList list = new PersistentObjectList(object1, "test");
list.add(object2);
byte[] bytes = serializationService.serialize(list);
PersistentObjectList list0 = serializationService.deserialize(bytes, PersistentObjectList.class);
assertNotNull(list0);
assertEquals(list.getRelationshipName(), list0.getRelationshipName());
assertEquals(list.getRelationshipOwner(), list0.getRelationshipOwner());
Object object0 = list0.get(0);
assertEquals(object2, object0);
}
use of org.apache.cayenne.util.PersistentObjectList in project cayenne by apache.
the class ClientServerChannelQueryIT method testSelectQueryPrefetchToMany.
@Test
public void testSelectQueryPrefetchToMany() throws Exception {
createTwoMtTable1sAnd2sDataSet();
SelectQuery q = new SelectQuery(ClientMtTable1.class, ExpressionFactory.exp("globalAttribute1 = 'g1'"));
q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
List<?> results = context.performQuery(q);
assertEquals(1, results.size());
ClientMtTable1 result = (ClientMtTable1) results.get(0);
List<?> holder = result.getTable2ArrayDirect();
assertNotNull(holder);
assertTrue(holder instanceof PersistentObjectList);
PersistentObjectList objectHolder = (PersistentObjectList) holder;
assertFalse(objectHolder.isFault());
assertEquals(2, objectHolder.size());
}
use of org.apache.cayenne.util.PersistentObjectList in project cayenne by apache.
the class ProtostuffPersistentObjectCollectionsTest method testPersistentObjectListWithWrapper.
@Test
public void testPersistentObjectListWithWrapper() throws IOException {
PersistentObjectList list = new PersistentObjectList(object1, "test");
list.add(object2);
byte[] bytes = serializationService.serialize(new ListWrapper(list));
ListWrapper lw = serializationService.deserialize(bytes, ListWrapper.class);
assertNotNull(lw.object);
assertTrue(lw.object instanceof PersistentObjectList);
PersistentObjectList list0 = (PersistentObjectList) lw.object;
assertEquals(list.getRelationshipName(), list0.getRelationshipName());
assertEquals(list.getRelationshipOwner(), list0.getRelationshipOwner());
Object object0 = list0.get(0);
assertEquals(object2, object0);
}
Aggregations