Search in sources :

Example 41 with ObjRelationship

use of org.apache.cayenne.map.ObjRelationship in project cayenne by apache.

the class EOModelProcessorTest method assertOneWayRelationships.

protected void assertOneWayRelationships(DataMap map) throws Exception {
    // assert that one way relationships are loaded properly
    // - Db loaded as two-way, obj - as one-way
    ObjEntity exhibitEntity = map.getObjEntity("Exhibit");
    ObjRelationship toTypeObject = exhibitEntity.getRelationship("toExhibitType");
    DbRelationship toTypeDB = exhibitEntity.getDbEntity().getRelationship("toExhibitType");
    assertNotNull(toTypeObject);
    assertNotNull(toTypeDB);
    assertNull(toTypeObject.getReverseRelationship());
    assertNotNull(toTypeDB.getReverseRelationship());
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjRelationship(org.apache.cayenne.map.ObjRelationship) DbRelationship(org.apache.cayenne.map.DbRelationship)

Example 42 with ObjRelationship

use of org.apache.cayenne.map.ObjRelationship in project cayenne by apache.

the class ClientSuperClassGenerationTest method testContainsPropertyImport.

@Test
public void testContainsPropertyImport() throws Exception {
    ObjEntity objEntity = new ObjEntity("TEST1");
    ObjAttribute attr = new ObjAttribute("attr");
    ObjRelationship rel = new ObjRelationship("rel");
    objEntity.addAttribute(attr);
    objEntity.addRelationship(rel);
    VelocityContext context = new VelocityContext();
    context.put(Artifact.OBJECT_KEY, objEntity);
    String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
    assertTrue(res.contains("org.apache.cayenne.exp.Property"));
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjRelationship(org.apache.cayenne.map.ObjRelationship) ObjAttribute(org.apache.cayenne.map.ObjAttribute) VelocityContext(org.apache.velocity.VelocityContext) Test(org.junit.Test)

Example 43 with ObjRelationship

use of org.apache.cayenne.map.ObjRelationship in project cayenne by apache.

the class ClientSuperClassGenerationTest method testContainsPropertyImportForRelationships.

@Test
public void testContainsPropertyImportForRelationships() throws Exception {
    ObjEntity objEntity = new ObjEntity("TEST1");
    ObjRelationship rel = new ObjRelationship("rel");
    objEntity.addRelationship(rel);
    VelocityContext context = new VelocityContext();
    context.put(Artifact.OBJECT_KEY, objEntity);
    String res = renderTemplate(ClientClassGenerationAction.SUPERCLASS_TEMPLATE, context);
    assertTrue(res.contains("org.apache.cayenne.exp.Property"));
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjRelationship(org.apache.cayenne.map.ObjRelationship) VelocityContext(org.apache.velocity.VelocityContext) Test(org.junit.Test)

Example 44 with ObjRelationship

use of org.apache.cayenne.map.ObjRelationship in project cayenne by apache.

the class SingleClassGenerationTest method testContainsPropertyImport.

@Test
public void testContainsPropertyImport() throws Exception {
    ObjEntity objEntity = new ObjEntity("TEST1");
    ObjAttribute attr = new ObjAttribute("attr");
    ObjRelationship rel = new ObjRelationship("rel");
    objEntity.addAttribute(attr);
    objEntity.addRelationship(rel);
    VelocityContext context = new VelocityContext();
    context.put(Artifact.OBJECT_KEY, objEntity);
    String res = renderTemplate(ClassGenerationAction.SINGLE_CLASS_TEMPLATE, context);
    assertTrue(res.contains("org.apache.cayenne.exp.Property"));
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjRelationship(org.apache.cayenne.map.ObjRelationship) ObjAttribute(org.apache.cayenne.map.ObjAttribute) VelocityContext(org.apache.velocity.VelocityContext) Test(org.junit.Test)

Example 45 with ObjRelationship

use of org.apache.cayenne.map.ObjRelationship in project cayenne by apache.

the class SuperClassGenerationTest method testContainsPropertyImportForRelationships.

@Test
public void testContainsPropertyImportForRelationships() throws Exception {
    ObjEntity objEntity = new ObjEntity("TEST1");
    ObjRelationship rel = new ObjRelationship("rel");
    objEntity.addRelationship(rel);
    VelocityContext context = new VelocityContext();
    context.put(Artifact.OBJECT_KEY, objEntity);
    String res = renderTemplate(ClassGenerationAction.SUPERCLASS_TEMPLATE, context);
    assertTrue(res.contains("org.apache.cayenne.exp.Property"));
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjRelationship(org.apache.cayenne.map.ObjRelationship) VelocityContext(org.apache.velocity.VelocityContext) Test(org.junit.Test)

Aggregations

ObjRelationship (org.apache.cayenne.map.ObjRelationship)84 ObjEntity (org.apache.cayenne.map.ObjEntity)48 ObjAttribute (org.apache.cayenne.map.ObjAttribute)27 DbRelationship (org.apache.cayenne.map.DbRelationship)26 Test (org.junit.Test)24 DbEntity (org.apache.cayenne.map.DbEntity)18 DbAttribute (org.apache.cayenne.map.DbAttribute)15 DbJoin (org.apache.cayenne.map.DbJoin)14 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)12 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)12 ObjectId (org.apache.cayenne.ObjectId)10 ToManyProperty (org.apache.cayenne.reflect.ToManyProperty)9 ToOneProperty (org.apache.cayenne.reflect.ToOneProperty)9 ArrayList (java.util.ArrayList)8 AttributeProperty (org.apache.cayenne.reflect.AttributeProperty)8 PropertyVisitor (org.apache.cayenne.reflect.PropertyVisitor)8 List (java.util.List)7 EJBQLException (org.apache.cayenne.ejbql.EJBQLException)7 DataMap (org.apache.cayenne.map.DataMap)7 HashMap (java.util.HashMap)6