use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testCompleteFieldStringGeneration.
@Test
public // Return field definition + annotations
void testCompleteFieldStringGeneration() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object1 = dataModel.addDataObject("com.test.Object1");
ObjectProperty prop1 = object1.addProperty("attribute1", "java.lang.String");
Annotation label = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Label.class.getName()));
label.setValue("value", "Attribute 1");
Annotation desc = new AnnotationImpl(annotationDefinitions.get(org.kie.api.definition.type.Description.class.getName()));
desc.setValue("value", "Description for Attribute 1");
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");
prop1.addAnnotation(label);
prop1.addAnnotation(desc);
prop1.addAnnotation(key);
prop1.addAnnotation(position);
GenerationContext generationContext = new GenerationContext(dataModelOracleDriver.createModel());
try {
String result = engine.generateCompleteFieldString(generationContext, prop1);
assertEquals(results.getProperty("testCompleteFieldStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testDefaultConstructorStringGeneration.
@Test
public void testDefaultConstructorStringGeneration() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object = dataModel.addDataObject("com.test.Object1");
GenerationContext generationContext = new GenerationContext(dataModel);
try {
String result = engine.generateDefaultConstructorString(generationContext, object);
assertEquals(results.getProperty("testDefaultConstructorStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testMethodStringGeneration.
@Test
public void testMethodStringGeneration() {
DataModel dataModel = dataModelOracleDriver.createModel();
Parameter parameter1 = new ParameterImpl(new TypeImpl("com.test.Object1"), "o1");
Parameter parameter2 = new ParameterImpl(new TypeImpl("com.test.Object1"), "o2");
Type returnType = new TypeImpl("com.test.Object1");
Method method = new MethodImpl("test", Arrays.asList(parameter1, parameter2), "return o1;", returnType, Visibility.PUBLIC);
DataObject object = dataModel.addDataObject("com.test.Object1");
object.addMethod(method);
GenerationContext generationContext = new GenerationContext(dataModel);
try {
String result = engine.generateMethodString(generationContext, method);
assertEquals(results.getProperty("testMethodStringGeneration"), results.getProperty("testMethodStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testFieldMutatorStringGeneration.
@Test
public void testFieldMutatorStringGeneration() {
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.generateFieldSetterString(generationContext, property);
assertEquals(results.getProperty("testFieldMutatorStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class GenerationEngineTest method testHashCodeStringGeneration.
@Test
public void testHashCodeStringGeneration() {
DataModel dataModel = dataModelOracleDriver.createModel();
DataObject object1 = dataModel.addDataObject("com.test.Object1");
DataObject object2 = dataModel.addDataObject("com.test.sub.Object2");
ObjectProperty prop1 = object1.addProperty("attribute1", "java.lang.String");
((ObjectPropertyImpl) prop1).setFileOrder(0);
ObjectProperty prop2 = object1.addProperty("attribute2", "java.lang.Boolean");
((ObjectPropertyImpl) prop2).setFileOrder(1);
ObjectProperty prop3 = object1.addProperty("attribute3", object2.getClassName());
((ObjectPropertyImpl) prop3).setFileOrder(2);
ObjectProperty prop4 = object1.addProperty("attribute4", "long");
((ObjectPropertyImpl) 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.generateHashCodeString(generationContext, object1);
assertEquals(results.getProperty("testHashCodeStringGeneration"), result);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations