use of org.kie.workbench.common.services.datamodeller.core.JavaEnum in project kie-wb-common by kiegroup.
the class ModuleDataModelOracleUtils method addEnumType.
private static void addEnumType(DataModel dataModel, String factType, ClassMetadata classMetadata) {
String packageName = NamingUtils.extractPackageName(factType);
String className = NamingUtils.extractClassName(factType);
Visibility visibility = DriverUtils.buildVisibility(classMetadata.getModifiers());
JavaEnum javaEnum = new JavaEnumImpl(packageName, className, visibility);
dataModel.addJavaEnum(javaEnum, ObjectSource.DEPENDENCY);
}
use of org.kie.workbench.common.services.datamodeller.core.JavaEnum in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriverTest method modelReadTest.
@Test
public void modelReadTest() {
try {
final SourceFilter pojo1Filter = javaType -> false;
final NestedClassFilter nestedClassFilter = javaType -> javaType.isClass() && javaType.getAnnotation(Generated.class) != null;
final MethodFilter methodFilter = method -> !method.isConstructor() && method.getAnnotation(Generated.class) != null;
FilterHolder filterHolder = mock(FilterHolder.class);
when(filterHolder.getSourceFilters()).thenReturn(Collections.singleton(pojo1Filter));
when(filterHolder.getNestedClassFilters()).thenReturn(Collections.singleton(nestedClassFilter));
when(filterHolder.getMethodFilters()).thenReturn(Collections.singleton(methodFilter));
JavaRoasterModelDriver javaRoasterModelDriver = new JavaRoasterModelDriver(ioService, rootPath, getClass().getClassLoader(), filterHolder);
ModelDriverResult modelDriverResult = javaRoasterModelDriver.loadModel();
DataModel dataModelOriginal = createModel();
assertNotNull(modelDriverResult);
assertNotNull(modelDriverResult.getDataModel());
assertEquals(dataModelOriginal.getDataObjects().size(), modelDriverResult.getDataModel().getDataObjects().size());
for (DataObject dataObject : dataModelOriginal.getDataObjects()) {
DataModelerAssert.assertEqualsDataObject(dataObject, modelDriverResult.getDataModel().getDataObject(dataObject.getClassName()));
}
for (JavaEnum javaEnum : dataModelOriginal.getJavaEnums()) {
DataModelerAssert.assertEqualsJavaEnum(javaEnum, modelDriverResult.getDataModel().getJavaEnum(javaEnum.getClassName()));
}
org.uberfire.backend.vfs.Path errorFile1 = Paths.convert(rootPath.resolve(ERROR_FILE1));
org.uberfire.backend.vfs.Path errorFile2 = Paths.convert(rootPath.resolve(ERROR_FILE2));
verifyErrorFilesWereDetected(modelDriverResult, errorFile1, errorFile2);
} catch (Exception e) {
e.printStackTrace();
fail("Test failed: " + e.getMessage());
}
}
use of org.kie.workbench.common.services.datamodeller.core.JavaEnum in project kie-wb-common by kiegroup.
the class ModuleDataModelOracleUtilsTest method createExpectedExternalEnums.
private List<JavaEnum> createExpectedExternalEnums() {
List<JavaEnum> result = new ArrayList<>();
result.add(new JavaEnumImpl(TEST_PACKAGE, "ExternalEnum1", Visibility.PUBLIC));
result.add(new JavaEnumImpl(TEST_PACKAGE, "ExternalEnum2", Visibility.PUBLIC));
return result;
}
use of org.kie.workbench.common.services.datamodeller.core.JavaEnum 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());
}
}
Aggregations