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();
}
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);
}
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);
}
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);
}
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);
}
Aggregations