use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ObjectStoreIT method testObjectsUnregistered.
@Test
public void testObjectsUnregistered() throws Exception {
DataRow row = new DataRow(10);
row.put("ARTIST_ID", new Integer(1));
row.put("ARTIST_NAME", "ArtistXYZ");
row.put("DATE_OF_BIRTH", new Date());
DataObject object = context.objectFromDataRow(Artist.class, row);
ObjectId oid = object.getObjectId();
// insert object into the ObjectStore
context.getObjectStore().registerNode(oid, object);
assertSame(object, context.getObjectStore().getNode(oid));
assertNotNull(context.getObjectStore().getCachedSnapshot(oid));
context.getObjectStore().objectsUnregistered(Collections.singletonList(object));
assertEquals(oid, object.getObjectId());
assertNull(context.getObjectStore().getNode(oid));
// in the future this may not be the case
assertNull(context.getObjectStore().getCachedSnapshot(oid));
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class PrefetchProcessorTreeBuilderIT method testBuildTreeNoPrefetches.
@Test
public void testBuildTreeNoPrefetches() {
final ClassDescriptor descriptor = resolver.getClassDescriptor("Artist");
List<DataRow> dataRows = new ArrayList<>();
dataRows.add(new DataRow(4));
dataRows.add(new DataRow(4));
QueryMetadata metadata = new MockQueryMetadata() {
@Override
public ClassDescriptor getClassDescriptor() {
return descriptor;
}
@Override
public ObjEntity getObjEntity() {
return descriptor.getEntity();
}
@Override
public DbEntity getDbEntity() {
return getObjEntity().getDbEntity();
}
@Override
public DataMap getDataMap() {
return getObjEntity().getDataMap();
}
@Override
public boolean isRefreshingObjects() {
return true;
}
@Override
public boolean isResolvingInherited() {
return true;
}
};
PrefetchTreeNode tree = new PrefetchTreeNode();
HierarchicalObjectResolver resolver = new HierarchicalObjectResolver(context, metadata);
PrefetchProcessorTreeBuilder builder = new PrefetchProcessorTreeBuilder(resolver, dataRows, new HashMap<>());
PrefetchProcessorNode processingTree = builder.buildTree(tree);
assertTrue(processingTree.getChildren().isEmpty());
assertFalse(processingTree.isPhantom());
assertFalse(processingTree.isPartitionedByParent());
assertTrue(processingTree.isDisjointPrefetch());
assertSame(dataRows, processingTree.getDataRows());
assertSame(descriptor.getEntity(), processingTree.getResolver().getEntity());
assertNull(processingTree.getIncoming());
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class SimpleIdIncrementalFaultListDataRowsIT method setUp.
@Before
public void setUp() throws Exception {
tArtist = new TableHelper(dbHelper, "ARTIST");
tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
createArtistsDataSet();
ObjectSelect<DataRow> q = ObjectSelect.dataRowQuery(Artist.class).pageSize(6).orderBy("db:ARTIST_ID", SortOrder.ASCENDING);
list = new SimpleIdIncrementalFaultList<>(context, q, 10000);
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class SimpleIdIncrementalFaultListDataRowsIT method testIndexOf1.
@Test
public void testIndexOf1() {
List<DataRow> artists = ObjectSelect.dataRowQuery(Artist.class, Artist.ARTIST_NAME.eq("artist20")).select(context);
assertEquals(1, artists.size());
DataRow row = artists.get(0);
assertEquals(19, list.indexOf(row));
DataRow clone = new DataRow(row);
assertEquals(19, list.indexOf(clone));
row.remove("ARTIST_ID");
assertEquals(-1, list.indexOf(row));
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class SimpleIdIncrementalFaultListDataRowsIT method testLastIndexOf2.
@Test
public void testLastIndexOf2() {
List<DataRow> artists = ObjectSelect.dataRowQuery(Artist.class, Artist.ARTIST_NAME.eq("artist20")).select(context);
assertEquals(1, artists.size());
DataRow row = artists.get(0);
assertEquals(19, list.lastIndexOf(row));
row.remove("ARTIST_ID");
assertEquals(-1, list.lastIndexOf(row));
}
Aggregations