use of org.kie.workbench.common.services.datamodeller.core.DataModel in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testMaxFieldsForConstructorsStringGeneration2.
@Test
public void testMaxFieldsForConstructorsStringGeneration2() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object1 = dataModel.addDataObject("com.test.MaxFieldsForConstructor2");
ObjectProperty prop1;
// The constructor for this data object should be generated, since we don't reach the limit.
for (int i = 0; i < GenerationTools.MAX_FIELDS_FOR_DEFAULT_CONSTRUCTOR; i++) {
prop1 = object1.addProperty("attribute" + normalize(i), "java.lang.String");
}
GenerationContext generationContext = new GenerationContext(dataModel);
try {
String result = engine.generateAllConstructorsString(generationContext, object1);
assertEquals(results.getProperty("testMaxFieldsForConstructorsStringGeneration2"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataModel in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testFieldStringGeneration.
@Test
public void testFieldStringGeneration() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object = dataModel.addDataObject("com.test.Object1");
ObjectProperty property = object.addProperty("attribute1", "java.lang.String");
GenerationContext generationContext = new GenerationContext(dataModel);
try {
String result = engine.generateFieldString(generationContext, property);
assertEquals(results.getProperty("testFieldStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataModel in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testEqualsStringGeneration.
@Test
public void testEqualsStringGeneration() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object1 = dataModel.addDataObject("com.test.Object1");
DataObject object2 = dataModel.addDataObject("com.test.sub.Object2");
ObjectPropertyImpl prop1 = (ObjectPropertyImpl) object1.addProperty("attribute1", "java.lang.String");
prop1.setFileOrder(0);
ObjectPropertyImpl prop2 = (ObjectPropertyImpl) object1.addProperty("attribute2", "java.lang.Boolean");
prop2.setFileOrder(1);
ObjectPropertyImpl prop3 = (ObjectPropertyImpl) object1.addProperty("attribute3", object2.getClassName());
prop3.setFileOrder(2);
ObjectPropertyImpl prop4 = (ObjectPropertyImpl) object1.addProperty("attribute4", "long");
prop4.setFileOrder(3);
Annotation key = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Key.class.getName()));
Annotation position = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Position.class.getName()));
position.setValue("value", "0");
prop4.addAnnotation(key);
prop4.addAnnotation(position);
position = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Position.class.getName()));
position.setValue("value", "1");
prop1.addAnnotation(key);
prop1.addAnnotation(position);
position = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Position.class.getName()));
position.setValue("value", "2");
prop2.addAnnotation(key);
prop2.addAnnotation(position);
position = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Position.class.getName()));
position.setValue("value", "3");
prop3.addAnnotation(position);
GenerationContext generationContext = new GenerationContext(dataModel);
try {
String result = engine.generateEqualsString(generationContext, object1);
assertEquals(results.getProperty("testEqualsStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataModel in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testMaxFieldsForConstructorsStringGeneration1.
@Test
public void testMaxFieldsForConstructorsStringGeneration1() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object1 = dataModel.addDataObject("com.test.MaxFieldsForConstructor1");
ObjectProperty prop1;
// The constructor for this data object should be generated, since we don't reach the limit.
for (int i = 0; i < GenerationTools.MAX_FIELDS_FOR_DEFAULT_CONSTRUCTOR - 1; i++) {
prop1 = object1.addProperty("attribute" + normalize(i), "java.lang.String");
((ObjectPropertyImpl) prop1).setFileOrder(i);
}
GenerationContext generationContext = new GenerationContext(dataModel);
try {
String result = engine.generateAllConstructorsString(generationContext, object1);
assertEquals(results.getProperty("testMaxFieldsForConstructorsStringGeneration1"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataModel in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testClassWithNestedClassStringGeneration.
@Test
public void testClassWithNestedClassStringGeneration() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object = dataModel.addDataObject("com.test.Object1");
GenerationContext generationContext = new GenerationContext(dataModel);
try {
String result = engine.generateNestedClassString(generationContext, object);
assertEquals(results.getProperty("testNestedClassStringGeneration"), results.getProperty("testNestedClassStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations