Search in sources :

Example 91 with ObjEntity

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

the class BaseTemplatesGenerationTest method setUp.

@Before
public void setUp() {
    cgenConfiguration = new CgenConfiguration(false);
    action = new ClassGenerationAction(cgenConfiguration);
    dataMap = new DataMap();
    dataMap.setDefaultPackage("test");
    objEntity = new ObjEntity();
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DataMap(org.apache.cayenne.map.DataMap) Before(org.junit.Before)

Example 92 with ObjEntity

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

the class PropertyUtilsTest method simpleStringDefinition.

@Test
public void simpleStringDefinition() throws Exception {
    importUtils.addType(StringProperty.class.getName());
    ObjEntity entity = new ObjEntity("test");
    ObjAttribute attribute = new ObjAttribute();
    attribute.setName("test");
    attribute.setType("java.lang.String");
    entity.addAttribute(attribute);
    String definition = propertyUtils.propertyDefinition(attribute);
    assertEquals("public static final StringProperty<String> TEST = PropertyFactory.createString(\"test\", String.class);", definition);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjAttribute(org.apache.cayenne.map.ObjAttribute) StringProperty(org.apache.cayenne.exp.property.StringProperty) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 93 with ObjEntity

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

the class PropertyUtilsTest method simpleNumericDefinition.

@Test
public void simpleNumericDefinition() throws Exception {
    importUtils.addType(NumericProperty.class.getName());
    ObjEntity entity = new ObjEntity("test");
    ObjAttribute attribute = new ObjAttribute();
    attribute.setName("test");
    attribute.setType("int");
    entity.addAttribute(attribute);
    String definition = propertyUtils.propertyDefinition(attribute);
    assertEquals("public static final NumericProperty<Integer> TEST = PropertyFactory.createNumeric(\"test\", Integer.class);", definition);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjAttribute(org.apache.cayenne.map.ObjAttribute) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NumericProperty(org.apache.cayenne.exp.property.NumericProperty) Test(org.junit.Test)

Example 94 with ObjEntity

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

the class PropertyUtilsTest method simpleNumericPropertyEmbDefinition.

@Test
public void simpleNumericPropertyEmbDefinition() throws ClassNotFoundException {
    importUtils.addType(EmbeddableProperty.class.getName());
    DataMap dataMap = new DataMap();
    ObjEntity entity = new ObjEntity();
    entity.setDataMap(dataMap);
    EmbeddedAttribute embeddedAttribute = new EmbeddedAttribute();
    embeddedAttribute.setName("a");
    embeddedAttribute.setType("test");
    embeddedAttribute.addAttributeOverride("testEmbAttr", "testPath");
    embeddedAttribute.setEntity(entity);
    EmbeddableAttribute attribute = new EmbeddableAttribute();
    attribute.setName("testEmbAttr");
    attribute.setType("int");
    Embeddable embeddable = new Embeddable();
    embeddable.setClassName("test");
    embeddable.addAttribute(attribute);
    dataMap.addEmbeddable(embeddable);
    String definition = propertyUtils.propertyDefinition(embeddedAttribute);
    assertEquals("public static final EmbeddableProperty<test> A = PropertyFactory.createEmbeddable(\"a\", test.class);", definition);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) EmbeddableProperty(org.apache.cayenne.exp.property.EmbeddableProperty) EmbeddedAttribute(org.apache.cayenne.map.EmbeddedAttribute) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable) Test(org.junit.Test)

Example 95 with ObjEntity

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

the class PropertyUtilsTest method customPropertyEmbDefinition.

@Test
public void customPropertyEmbDefinition() throws ClassNotFoundException {
    importUtils.addType(CustomProperty.class.getName());
    importUtils.addType(TimestampType.class.getName());
    DataMap dataMap = new DataMap();
    ObjEntity entity = new ObjEntity();
    entity.setDataMap(dataMap);
    EmbeddedAttribute embeddedAttribute = new EmbeddedAttribute();
    embeddedAttribute.setName("a");
    embeddedAttribute.setType("test");
    embeddedAttribute.addAttributeOverride("testEmbAttr", "testPath");
    embeddedAttribute.setEntity(entity);
    EmbeddableAttribute attribute = new EmbeddableAttribute();
    attribute.setName("testEmbAttr");
    attribute.setType("org.apache.cayenne.access.types.TimestampType");
    Embeddable embeddable = new Embeddable();
    embeddable.setClassName("test");
    embeddable.addAttribute(attribute);
    dataMap.addEmbeddable(embeddable);
    String definition = propertyUtils.propertyDefinition(attribute);
    assertEquals("public static final CustomProperty<TimestampType> TEST_EMB_ATTR = new CustomProperty(\"testEmbAttr\", TimestampType.class);", definition);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) CustomProperty(org.apache.cayenne.gen.mock.CustomProperty) TimestampType(org.apache.cayenne.access.types.TimestampType) EmbeddedAttribute(org.apache.cayenne.map.EmbeddedAttribute) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable) Test(org.junit.Test)

Aggregations

ObjEntity (org.apache.cayenne.map.ObjEntity)294 Test (org.junit.Test)110 DbEntity (org.apache.cayenne.map.DbEntity)72 ObjAttribute (org.apache.cayenne.map.ObjAttribute)68 ObjRelationship (org.apache.cayenne.map.ObjRelationship)62 DataMap (org.apache.cayenne.map.DataMap)57 DbAttribute (org.apache.cayenne.map.DbAttribute)37 DbRelationship (org.apache.cayenne.map.DbRelationship)29 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)27 ObjectId (org.apache.cayenne.ObjectId)26 ClassDescriptor (org.apache.cayenne.reflect.ClassDescriptor)22 ArrayList (java.util.ArrayList)19 Embeddable (org.apache.cayenne.map.Embeddable)18 EntityResolver (org.apache.cayenne.map.EntityResolver)17 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)16 Expression (org.apache.cayenne.exp.Expression)15 Persistent (org.apache.cayenne.Persistent)12 EntityEvent (org.apache.cayenne.map.event.EntityEvent)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 Entity (org.apache.cayenne.map.Entity)11