Search in sources :

Example 1 with CustomProperty

use of org.apache.cayenne.gen.mock.CustomProperty 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)

Example 2 with CustomProperty

use of org.apache.cayenne.gen.mock.CustomProperty in project cayenne by apache.

the class PropertyUtilsTest method customPropertyDefinition.

@Test
public void customPropertyDefinition() throws ClassNotFoundException {
    importUtils.addType(CustomProperty.class.getName());
    importUtils.addType(TimestampType.class.getName());
    ObjEntity entity = new ObjEntity("test");
    ObjAttribute attribute = new ObjAttribute();
    attribute.setName("test");
    attribute.setType("org.apache.cayenne.access.types.TimestampType");
    entity.addAttribute(attribute);
    String definition = propertyUtils.propertyDefinition(attribute);
    assertEquals("public static final CustomProperty<TimestampType> TEST = new CustomProperty(\"test\", TimestampType.class);", definition);
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjAttribute(org.apache.cayenne.map.ObjAttribute) CustomProperty(org.apache.cayenne.gen.mock.CustomProperty) TimestampType(org.apache.cayenne.access.types.TimestampType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

TimestampType (org.apache.cayenne.access.types.TimestampType)2 CustomProperty (org.apache.cayenne.gen.mock.CustomProperty)2 ObjEntity (org.apache.cayenne.map.ObjEntity)2 Test (org.junit.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 DataMap (org.apache.cayenne.map.DataMap)1 Embeddable (org.apache.cayenne.map.Embeddable)1 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)1 EmbeddedAttribute (org.apache.cayenne.map.EmbeddedAttribute)1 ObjAttribute (org.apache.cayenne.map.ObjAttribute)1