use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class EOModelProcessorTest method testLoadModelWithDependencies.
@Test
public void testLoadModelWithDependencies() throws Exception {
URL url = getClass().getClassLoader().getResource("wotests/cross-model-relationships.eomodeld/");
assertNotNull(url);
DataMap map = processor.loadEOModel(url);
ObjEntity entity = map.getObjEntity("CrossModelRelTest");
assertNotNull(entity);
ObjAttribute a1 = entity.getAttribute("testAttribute");
assertNotNull(a1);
DbAttribute da1 = a1.getDbAttribute();
assertNotNull(da1);
assertSame(da1, entity.getDbEntity().getAttribute("TEST_ATTRIBUTE"));
// for now cross model relationships are simply ignored
// eventually we must handle those...
assertEquals(0, entity.getRelationships().size());
assertEquals(0, entity.getDbEntity().getRelationships().size());
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class EOModelProcessorTest method testLoadFlattened.
@Test
public void testLoadFlattened() throws Exception {
URL url = getClass().getClassLoader().getResource("wotests/flattened.eomodeld/");
assertNotNull(url);
// see CAY-1806
DataMap map = processor.loadEOModel(url);
ObjEntity artistE = map.getObjEntity("Artist");
assertNotNull(artistE);
assertEquals(2, artistE.getRelationships().size());
assertNotNull(artistE.getRelationship("exhibitArray"));
assertNotNull(artistE.getRelationship("artistExhibitArray"));
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class EOModelProcessorTest method assertLoaded.
protected void assertLoaded(String mapName, DataMap map) throws Exception {
assertNotNull(map);
assertEquals(mapName, map.getName());
// check obj entities
ObjEntity artistE = map.getObjEntity("Artist");
assertNotNull(artistE);
assertEquals("Artist", artistE.getName());
// check Db entities
DbEntity artistDE = map.getDbEntity("ARTIST");
DbEntity artistDE1 = artistE.getDbEntity();
assertSame(artistDE, artistDE1);
// check attributes
ObjAttribute a1 = artistE.getAttribute("artistName");
assertNotNull(a1);
DbAttribute da1 = a1.getDbAttribute();
assertNotNull(da1);
assertSame(da1, artistDE.getAttribute("ARTIST_NAME"));
// check ObjRelationships
ObjRelationship rel = artistE.getRelationship("artistExhibitArray");
assertNotNull(rel);
assertEquals(1, rel.getDbRelationships().size());
// check DbRelationships
DbRelationship drel = artistDE.getRelationship("artistExhibitArray");
assertNotNull(drel);
assertSame(drel, rel.getDbRelationships().get(0));
// flattened relationships
ObjRelationship frel = artistE.getRelationship("exhibitArray");
assertNotNull(frel);
assertEquals(2, frel.getDbRelationships().size());
// storing data map may uncover some inconsistencies
PrintWriter mockupWriter = new NullPrintWriter();
map.encodeAsXML(new XMLEncoder(mockupWriter), new EmptyConfigurationNodeVisitor());
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class EOModelProcessorInheritanceTest method testLoadFlattenedRelationship.
@Test
public void testLoadFlattenedRelationship() throws Exception {
DataMap map = processor.loadEOModel(url);
ObjEntity e1 = map.getObjEntity("HelperFlatEntity");
assertNotNull(e1);
ObjRelationship fr = (ObjRelationship) e1.getRelationship("singleTables");
assertNotNull(fr);
assertEquals("singleTableJoins.toSingleTable", fr.getDbRelationshipPath());
assertEquals("SingleTableConcreteEntityOne", fr.getTargetEntityName());
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class EOModelPrototypesTest method testOverridingAttributes.
// TODO: move this test to EOModelProcessorInheritanceTst. The original problem had
// nothing to do with prototypes...
@Test
public void testOverridingAttributes() throws Exception {
DataMap map = new EOModelProcessor().loadEOModel(url);
ObjEntity estimateOE = map.getObjEntity("Estimate");
assertSame(estimateOE, estimateOE.getAttribute("created").getEntity());
assertSame(estimateOE, estimateOE.getAttribute("estimateNumber").getEntity());
}
Aggregations