Search in sources :

Example 1 with EmbeddableProperty

use of org.apache.cayenne.exp.property.EmbeddableProperty 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)

Aggregations

EmbeddableProperty (org.apache.cayenne.exp.property.EmbeddableProperty)1 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 ObjEntity (org.apache.cayenne.map.ObjEntity)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1