use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriverTest method createNestedClassUpdateTestResult.
private DataObject createNestedClassUpdateTestResult() {
DataObject dataObject = createDataObject("org.kie.workbench.common.services.datamodeller.driver.package5", "NestedClassUpdateTestResult", null);
JavaClass nestedClass = new JavaClassImpl("", "UpdatedNestedClass");
nestedClass.addInterface("java.io.Serializable");
nestedClass.addInterface("ParametrizedInterface<Double>");
Annotation generatedAnnotation = createAnnotation(Generated.class);
generatedAnnotation.setValue("value", Arrays.asList("foo.bar.Generator"));
nestedClass.addAnnotation(generatedAnnotation);
MethodImpl method = new MethodImpl("updatedMethod", Collections.EMPTY_LIST, "", new TypeImpl(void.class.getName()), Visibility.PUBLIC);
generatedAnnotation = createAnnotation(Generated.class);
generatedAnnotation.setValue("value", Arrays.asList("foo.bar.Generator"));
method.addAnnotation(generatedAnnotation);
nestedClass.addMethod(method);
dataObject.addNestedClass(nestedClass);
return dataObject;
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriverTest method createAnnotationsUpdateTest.
private DataObject createAnnotationsUpdateTest() {
DataObject dataObject = createDataObject("org.kie.workbench.common.services.datamodeller.driver.package3", "AnnotationsUpdateTest", null);
dataObject.addAnnotation(createAnnotationValuesAnnotation());
dataObject.addAnnotation(createClassAnnotation());
dataObject.addAnnotation(createEnumsAnnotation());
dataObject.addAnnotation(createPrimitivesAnnotation());
return dataObject;
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class ModuleDataModelOracleUtilsTest method loadExternalDepsTest.
@Test
public void loadExternalDepsTest() {
DataModel dataModel = new DataModelImpl();
try {
ModuleDataModelOracleUtils.loadExternalDependencies(dataModel, dataModelOracle, ModuleDataModelOracleUtilsTest.class.getClassLoader());
// check that the expected classes were properly loaded.
List<DataObject> expectedExternalClasses = createExpectedExternalClasses();
assertEquals(expectedExternalClasses.size(), dataModel.getExternalClasses().size());
for (DataObject externalClass : dataModel.getExternalClasses()) {
// properties read from DMO are not necessary sorted.
sortProperties(externalClass);
assertTrue(expectedExternalClasses.contains(externalClass));
}
// check that the expected enums where properly loaded.
List<JavaEnum> expectedExternalEnums = createExpectedExternalEnums();
assertEquals(expectedExternalEnums.size(), dataModel.getDependencyJavaEnums().size());
for (JavaEnum externalEnum : dataModel.getDependencyJavaEnums()) {
assertTrue(expectedExternalEnums.contains(externalEnum));
}
} catch (Exception e) {
fail("External deps loading test failed: " + e.getMessage());
}
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class ModuleDataModelOracleUtilsTest method createExpectedExternalClasses.
private List<DataObject> createExpectedExternalClasses() {
List<DataObject> result = new ArrayList<>();
DataObject dataObject1 = new DataObjectImpl(TEST_PACKAGE, "ExternalPojo1");
dataObject1.setSuperClassName(Object.class.getName());
dataObject1.addProperty("field1", String.class.getName());
dataObject1.addProperty("field2", String.class.getName());
result.add(dataObject1);
DataObject dataObject2 = new DataObjectImpl(TEST_PACKAGE, "ExternalPojo2");
dataObject2.setSuperClassName(Object.class.getName());
dataObject2.addProperty("field3", String.class.getName());
dataObject2.addProperty("field4", String.class.getName());
result.add(dataObject2);
return result;
}
use of org.kie.workbench.common.services.datamodeller.core.DataObject in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriverTest method createAnnotationsUpdateTestResult.
private DataObject createAnnotationsUpdateTestResult() {
DataObject dataObject = createDataObject("org.kie.workbench.common.services.datamodeller.driver.package3", "AnnotationsUpdateTestResult", null);
dataObject.addAnnotation(createMarkerAnnotation());
/*
@PrimitivesAnnotation( byteParam = ( byte ) 2, byteArrayParam = { 3, 4 },
shortParam = 2, shortArrayParam = { 3, 4 },
stringParam = "2", stringArrayParam = { "3", "4" }
*/
Annotation primitivesAnnotation = createAnnotation(PrimitivesAnnotation.class);
primitivesAnnotation.setValue("byteParam", new Byte("2"));
// primitivesAnnotation.setValue( "byteArrayParam", "{3,4}" );
primitivesAnnotation.setValue("byteArrayParam", createArrayParam((byte) 3, (byte) 4));
primitivesAnnotation.setValue("shortParam", new Short("2"));
primitivesAnnotation.setValue("shortArrayParam", createArrayParam((short) 3, (short) 4));
primitivesAnnotation.setValue("stringParam", "2");
primitivesAnnotation.setValue("stringArrayParam", createArrayParam("3", "4"));
dataObject.addAnnotation(primitivesAnnotation);
/*
@EnumsAnnotation( enum1Param = TestEnums.ENUM1.VALUE2, enum1ArrayParam = { TestEnums.ENUM1.VALUE3 },
enum2Param = TestEnums.ENUM2.VALUE2, enum2ArrayParam = { TestEnums.ENUM2.VALUE3 }
)
*/
Annotation enumsAnnotation = createAnnotation(EnumsAnnotation.class);
enumsAnnotation.setValue("enum1Param", TestEnums.ENUM1.VALUE2.toString());
// enumsAnnotation.setValue( "enum1ArrayParam", "{TestEnums.ENUM1.VALUE3}" );
enumsAnnotation.setValue("enum1ArrayParam", createEnumArrayParam(TestEnums.ENUM1.VALUE3));
enumsAnnotation.setValue("enum2Param", TestEnums.ENUM2.VALUE2.toString());
// enumsAnnotation.setValue( "enum2ArrayParam", "{TestEnums.ENUM2.VALUE3}" );
enumsAnnotation.setValue("enum2ArrayParam", createEnumArrayParam(TestEnums.ENUM2.VALUE3));
dataObject.addAnnotation(enumsAnnotation);
/*
@ClassAnnotation( classParam = java.util.Collection.class,
classArrayParam = { List.class }
)
*/
Annotation classAnnotation = createAnnotation(ClassAnnotation.class);
classAnnotation.setValue("classParam", "java.util.Collection.class");
classAnnotation.setValue("classArrayParam", createArrayParam("List.class"));
dataObject.addAnnotation(classAnnotation);
/*
@AnnotationValuesAnnotation( primitivesParam = @PrimitivesAnnotation( stringParam = "\"line1\" \n line2 \\ \n line3" ),
primitivesArrayParam = { @PrimitivesAnnotation( intParam = 2 ), @PrimitivesAnnotation( intParam = 3 ) },
enumsParam = @EnumsAnnotation( enum1Param = TestEnums.ENUM1.VALUE2 ),
enumsArrayParam = { @EnumsAnnotation( enum1Param = TestEnums.ENUM1.VALUE2 ), @EnumsAnnotation( enum1Param = TestEnums.ENUM1.VALUE3 ) },
classAnnotationParam = @ClassAnnotation( classParam = Set.class ),
classAnnotationArrayParam = { @ClassAnnotation( classParam = Set.class ), @ClassAnnotation( classParam = Set.class ) }
)
*/
Annotation annotationValuesAnnotation = createAnnotation(AnnotationValuesAnnotation.class);
// annotation.setValue( "primitivesParam", "@PrimitivesAnnotation(stringParam="\"line1\" \n line2 \\ \n line3")" );
Annotation primitivesParamValue = createAnnotation(PrimitivesAnnotation.class);
// construct the value -> "\"line1\" \n line2 \\ \n line3"
StringBuilder stringParamBuilder = new StringBuilder();
stringParamBuilder.append('"').append("line1").append('"').append(" ").append('\n');
stringParamBuilder.append(" line2 ").append('\\').append(" ").append('\n');
stringParamBuilder.append(" line3");
primitivesParamValue.setValue("stringParam", stringParamBuilder.toString());
annotationValuesAnnotation.setValue("primitivesParam", primitivesParamValue);
// @PrimitivesAnnotation(intParam=1)
Annotation primitiveValue1 = createAnnotation(PrimitivesAnnotation.class);
primitiveValue1.setValue("intParam", 2);
// @PrimitivesAnnotation(intParam=3)
Annotation primitiveValue2 = createAnnotation(PrimitivesAnnotation.class);
primitiveValue2.setValue("intParam", 3);
List<Annotation> primitivesArrayParamValue = new ArrayList<Annotation>();
primitivesArrayParamValue.add(primitiveValue1);
primitivesArrayParamValue.add(primitiveValue2);
// annotation.setValue( "primitivesArrayParam", "{@PrimitivesAnnotation(intParam=2),@PrimitivesAnnotation(intParam=3)}" );
annotationValuesAnnotation.setValue("primitivesArrayParam", primitivesArrayParamValue);
// annotation.setValue( "enumsParam", "@EnumsAnnotation(enum1Param=TestEnums.ENUM1.VALUE2)" );
Annotation enumsParamValue = createAnnotation(EnumsAnnotation.class);
enumsParamValue.setValue("enum1Param", TestEnums.ENUM1.VALUE2.toString());
annotationValuesAnnotation.setValue("enumsParam", enumsParamValue);
// annotation.setValue( "enumsArrayParam", "{@EnumsAnnotation(enum1Param=TestEnums.ENUM1.VALUE2),@EnumsAnnotation(enum1Param=TestEnums.ENUM1.VALUE3)}" );
Annotation enumArrayParam1 = createAnnotation(EnumsAnnotation.class);
enumArrayParam1.setValue("enum1Param", TestEnums.ENUM1.VALUE2.toString());
Annotation enumArrayParam2 = createAnnotation(EnumsAnnotation.class);
enumArrayParam2.setValue("enum1Param", TestEnums.ENUM1.VALUE3.toString());
List<Annotation> enumVarrayValues = new ArrayList<Annotation>();
enumVarrayValues.add(enumArrayParam1);
enumVarrayValues.add(enumArrayParam2);
annotationValuesAnnotation.setValue("enumsArrayParam", enumVarrayValues);
// annotation.setValue( "classAnnotationParam", "@ClassAnnotation(classParam=Set.class)" );
Annotation classAnnotationParamValue = createAnnotation(ClassAnnotation.class);
classAnnotationParamValue.setValue("classParam", "Set.class");
annotationValuesAnnotation.setValue("classAnnotationParam", classAnnotationParamValue);
// annotation.setValue( "classAnnotationArrayParam", "{@ClassAnnotation(classParam=Set.class),@ClassAnnotation(classParam=Set.class)}" );
Annotation classAnnotationArrayParamValue1 = createAnnotation(ClassAnnotation.class);
classAnnotationArrayParamValue1.setValue("classParam", "Set.class");
Annotation classAnnotationArrayParamValue2 = createAnnotation(ClassAnnotation.class);
classAnnotationArrayParamValue2.setValue("classParam", "Set.class");
List<Annotation> classAnnotationArrayParamValue = new ArrayList<Annotation>();
classAnnotationArrayParamValue.add(classAnnotationArrayParamValue1);
classAnnotationArrayParamValue.add(classAnnotationArrayParamValue2);
annotationValuesAnnotation.setValue("classAnnotationArrayParam", classAnnotationArrayParamValue);
dataObject.addAnnotation(annotationValuesAnnotation);
return dataObject;
}
Aggregations