use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class SyncMessageTest method testHessianSerialization.
@Test
public void testHessianSerialization() throws Exception {
// id must be a serializable object; source doesn't have to be
ObjectContext source = mock(ObjectContext.class);
GraphDiff diff = new NodeCreateOperation("id-string");
SyncMessage message = new SyncMessage(source, DataChannel.FLUSH_NOCASCADE_SYNC, diff);
Object d = HessianUtil.cloneViaClientServerSerialization(message, new EntityResolver());
assertNotNull(d);
assertTrue(d instanceof SyncMessage);
SyncMessage ds = (SyncMessage) d;
assertNull(ds.getSource());
assertEquals(message.getType(), ds.getType());
assertNotNull(ds.getSenderChanges());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class BatchActionGeneratedIT method testHasGeneratedKeys1.
@Test
public void testHasGeneratedKeys1() throws Exception {
EntityResolver resolver = runtime.getChannel().getEntityResolver();
// test with adapter that supports keys
JdbcAdapter adapter = buildAdapter(true);
InsertBatchQuery batch1 = new InsertBatchQuery(resolver.getObjEntity(GeneratedColumnTestEntity.class).getDbEntity(), 5);
DataNode node = new DataNode();
node.setAdapter(adapter);
node.setEntityResolver(resolver);
node.setRowReaderFactory(mock(RowReaderFactory.class));
assertTrue(new BatchAction(batch1, node, false).hasGeneratedKeys());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class BatchActionIT method testHasGeneratedKeys1.
@Test
public void testHasGeneratedKeys1() throws Exception {
EntityResolver resolver = runtime.getChannel().getEntityResolver();
// test with adapter that supports keys
JdbcAdapter adapter = buildAdapter(true);
DataNode node = new DataNode();
node.setAdapter(adapter);
node.setEntityResolver(resolver);
node.setRowReaderFactory(mock(RowReaderFactory.class));
InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
assertFalse(new BatchAction(batch2, node, false).hasGeneratedKeys());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class BatchActionIT method testHasGeneratedKeys2.
@Test
public void testHasGeneratedKeys2() throws Exception {
EntityResolver resolver = runtime.getChannel().getEntityResolver();
// test with adapter that does not support keys...
JdbcAdapter adapter = buildAdapter(false);
DataNode node = new DataNode();
node.setAdapter(adapter);
node.setEntityResolver(resolver);
node.setRowReaderFactory(mock(RowReaderFactory.class));
InsertBatchQuery batch2 = new InsertBatchQuery(resolver.getObjEntity(Artist.class).getDbEntity(), 5);
assertFalse(new BatchAction(batch2, node, false).hasGeneratedKeys());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class CayenneGeneratorMapLoaderAction method getMainDataMap.
DataMap getMainDataMap() throws MalformedURLException {
if (mainDataMap == null) {
DataMapLoader loader = createLoader();
DataMap mainDataMap = loadDataMap(loader, mainDataMapFile);
if (additionalDataMapFiles != null) {
EntityResolver entityResolver = new EntityResolver();
entityResolver.addDataMap(mainDataMap);
mainDataMap.setNamespace(entityResolver);
for (File additionalDataMapFile : additionalDataMapFiles) {
DataMap dataMap = loadDataMap(loader, additionalDataMapFile);
entityResolver.addDataMap(dataMap);
dataMap.setNamespace(entityResolver);
}
}
this.mainDataMap = mainDataMap;
}
return mainDataMap;
}
Aggregations