Search in sources :

Example 1 with UpdateInfo

use of org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriverTest method importsUpdateTest.

@Test
public void importsUpdateTest() throws Exception {
    Path importsUpdateTestFilePath = rootPath.resolve("package6").resolve("ImportsUpdateTest.java");
    String source = ioService.readAllString(importsUpdateTestFilePath);
    JavaClassSource importsUpdateTestJavaClassSource = (JavaClassSource) Roaster.parse(source);
    ClassLoader classLoader = getClass().getClassLoader();
    ClassTypeResolver classTypeResolver = DriverUtils.createClassTypeResolver(importsUpdateTestJavaClassSource, classLoader);
    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, classLoader, filterHolder);
    ModelDriverResult result = javaRoasterModelDriver.loadDataObject(source, importsUpdateTestFilePath);
    DataObject importsUpdateTest = result.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package6.ImportsUpdateTest");
    importsUpdateTest.addImport(new ImportImpl(List.class.getName()));
    importsUpdateTest.addImport(new ImportImpl(ArrayList.class.getName()));
    importsUpdateTest.setName("ImportsUpdateTestResult");
    Path expectedFilePath = rootPath.resolve("package6").resolve("ImportsUpdateTestResult.java");
    String expectedSource = ioService.readAllString(expectedFilePath);
    ModelDriverResult expectedResult = javaRoasterModelDriver.loadDataObject(expectedSource, expectedFilePath);
    DataObject importsUpdateTestResult = expectedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package6.ImportsUpdateTestResult");
    DataModelerAssert.assertEqualsDataObject(importsUpdateTestResult, importsUpdateTest);
    DataModelerAssert.assertEqualsImports(importsUpdateTestResult.getImports(), importsUpdateTest.getImports());
    javaRoasterModelDriver.updateSource(importsUpdateTestJavaClassSource, importsUpdateTest, new UpdateInfo(), classTypeResolver);
    ModelDriverResult updatedResult = javaRoasterModelDriver.loadDataObject(importsUpdateTestJavaClassSource.toString(), importsUpdateTestFilePath);
    DataModelerAssert.assertEqualsDataObject(importsUpdateTestResult, updatedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package6.ImportsUpdateTestResult"));
    DataModelerAssert.assertEqualsImports(importsUpdateTestResult.getImports(), updatedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package6.ImportsUpdateTestResult").getImports());
}
Also used : Path(org.uberfire.java.nio.file.Path) Description(org.kie.api.definition.type.Description) Arrays(java.util.Arrays) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) Timestamp(org.kie.api.definition.type.Timestamp) Label(org.kie.api.definition.type.Label) TestAnnotation1(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation1) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) LoggerFactory(org.slf4j.LoggerFactory) DataModelerAssert(org.kie.workbench.common.services.datamodeller.DataModelerAssert) Paths(org.uberfire.backend.server.util.Paths) Generated(javax.annotation.Generated) Matcher(java.util.regex.Matcher) Roaster(org.jboss.forge.roaster.Roaster) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) SequenceGenerator(javax.persistence.SequenceGenerator) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) JavaEnum(org.kie.workbench.common.services.datamodeller.core.JavaEnum) URI(java.net.URI) Instance(javax.enterprise.inject.Instance) Entity(javax.persistence.Entity) ParameterImpl(org.kie.workbench.common.services.datamodeller.core.impl.ParameterImpl) UniqueConstraint(javax.persistence.UniqueConstraint) ClassReactive(org.kie.api.definition.type.ClassReactive) JavaTypeInfo(org.kie.workbench.common.services.datamodeller.core.JavaTypeInfo) ENUM3(org.kie.workbench.common.services.datamodeller.annotations.ENUM3) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) List(java.util.List) AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) DataModelImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) Role(org.kie.api.definition.type.Role) JavaClassImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaClassImpl) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) Expires(org.kie.api.definition.type.Expires) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Parameter(org.kie.workbench.common.services.datamodeller.core.Parameter) Mock(org.mockito.Mock) Path(org.uberfire.java.nio.file.Path) RunWith(org.junit.runner.RunWith) DriverUtils(org.kie.workbench.common.services.datamodeller.util.DriverUtils) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) Type(org.kie.workbench.common.services.datamodeller.core.Type) ArrayList(java.util.ArrayList) Table(javax.persistence.Table) TypeSafe(org.kie.api.definition.type.TypeSafe) Duration(org.kie.api.definition.type.Duration) DataModel(org.kie.workbench.common.services.datamodeller.core.DataModel) Before(org.junit.Before) Logger(org.slf4j.Logger) JavaEnumImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaEnumImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) IOException(java.io.IOException) Test(org.junit.Test) Method(org.kie.workbench.common.services.datamodeller.core.Method) InputStreamReader(java.io.InputStreamReader) File(java.io.File) ImportImpl(org.kie.workbench.common.services.datamodeller.core.impl.ImportImpl) DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) MethodImpl(org.kie.workbench.common.services.datamodeller.core.impl.MethodImpl) Mockito(org.mockito.Mockito) TestEnums(org.kie.workbench.common.services.datamodeller.annotations.TestEnums) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Position(org.kie.api.definition.type.Position) JavaClass(org.kie.workbench.common.services.datamodeller.core.JavaClass) TypeImpl(org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) IOService(org.uberfire.io.IOService) BufferedReader(java.io.BufferedReader) Key(org.kie.api.definition.type.Key) Assert(org.junit.Assert) Collections(java.util.Collections) Visibility(org.kie.workbench.common.services.datamodeller.core.Visibility) InputStream(java.io.InputStream) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) ImportImpl(org.kie.workbench.common.services.datamodeller.core.impl.ImportImpl) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) Test(org.junit.Test)

Example 2 with UpdateInfo

use of org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriverTest method methodUpdateTest.

@Test
public void methodUpdateTest() {
    try {
        // First read the MethodsUpdateTest
        Path methodsUpdateTestFilePath = rootPath.resolve("package4").resolve("MethodsUpdateTest.java");
        String source = ioService.readAllString(methodsUpdateTestFilePath);
        JavaClassSource methodsUpdateTestJavaClassSource = (JavaClassSource) Roaster.parse(source);
        ClassLoader classLoader = getClass().getClassLoader();
        ClassTypeResolver classTypeResolver = DriverUtils.createClassTypeResolver(methodsUpdateTestJavaClassSource, classLoader);
        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, classLoader, filterHolder);
        ModelDriverResult result = javaRoasterModelDriver.loadDataObject(source, methodsUpdateTestFilePath);
        // 1) read the MethodsUpdateTest
        DataObject methodsUpdateTest = result.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package4.MethodsUpdateTest");
        // 2) modify the MethodsUpdateTest according to the expected result.
        Method getTestStringMethod = methodsUpdateTest.getMethod("getTestString", Arrays.asList(List.class.getName()));
        Type methodReturnType = new TypeImpl(List.class.getName(), Arrays.asList(new TypeImpl(Integer.class.getName())));
        // List<Integer>
        getTestStringMethod.setReturnType(methodReturnType);
        Type parameterType1 = new TypeImpl(List.class.getName(), Arrays.asList(new TypeImpl(List.class.getName(), Arrays.asList(new TypeImpl("org.kie.workbench.common.services.datamodeller.driver.package4.MethodsUpdateTestResult")))));
        Parameter parameter1 = new ParameterImpl(parameterType1, "methodUpdateTestResultList");
        Type parameterType2 = new TypeImpl(int.class.getName());
        Parameter parameter2 = new ParameterImpl(parameterType2, "intParameter");
        getTestStringMethod.getParameters().clear();
        // ( List<List<MethodsUpdateTestResult>> methodUpdateTestResultList, int intParameter )
        getTestStringMethod.setParameters(Arrays.asList(parameter1, parameter2));
        getTestStringMethod.setBody("return Arrays.asList(1);");
        Method noOpMethodWithTestAnnotation = methodsUpdateTest.getMethod("noOpMethodWithTestAnnotation", Collections.EMPTY_LIST);
        noOpMethodWithTestAnnotation.setName("noOpMethodWithTestAnnotationUpdated");
        noOpMethodWithTestAnnotation.setBody("return 1;");
        noOpMethodWithTestAnnotation.setReturnType(new TypeImpl(Integer.class.getName()));
        // @TestAnnotation1("annotationParameterUpdated")
        Annotation testAnnotation = noOpMethodWithTestAnnotation.getAnnotation(TestAnnotation1.class.getName());
        testAnnotation.setValue("value", "annotationParameterUpdated");
        methodsUpdateTest.setName("MethodsUpdateTestResult");
        // 3) compare the modified data object with the expected data object.
        Path expectedFilePath = rootPath.resolve("package4").resolve("MethodsUpdateTestResult.java");
        String expectedSource = ioService.readAllString(expectedFilePath);
        JavaClassSource expectedJavaClassSource = (JavaClassSource) Roaster.parse(expectedSource);
        ModelDriverResult expectedResult = javaRoasterModelDriver.loadDataObject(expectedSource, expectedFilePath);
        DataObject methodsUpdateTestResult = expectedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package4.MethodsUpdateTestResult");
        // First check, the modified data object in memory should be the same as the readed from the model.
        DataModelerAssert.assertEqualsDataObject(methodsUpdateTestResult, methodsUpdateTest);
        // Second check, update the JavaClassSource corresponding to the MethodsUpdateTest
        javaRoasterModelDriver.updateSource(methodsUpdateTestJavaClassSource, methodsUpdateTest, new UpdateInfo(), classTypeResolver);
        ModelDriverResult updatedResult = javaRoasterModelDriver.loadDataObject(methodsUpdateTestJavaClassSource.toString(), methodsUpdateTestFilePath);
        // and now compare the updatedResult with the expected value.
        DataModelerAssert.assertEqualsDataObject(methodsUpdateTestResult, updatedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package4.MethodsUpdateTestResult"));
        logger.debug(methodsUpdateTestJavaClassSource.toString());
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test failed: " + e.getMessage());
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) Description(org.kie.api.definition.type.Description) Arrays(java.util.Arrays) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) Timestamp(org.kie.api.definition.type.Timestamp) Label(org.kie.api.definition.type.Label) TestAnnotation1(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation1) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) LoggerFactory(org.slf4j.LoggerFactory) DataModelerAssert(org.kie.workbench.common.services.datamodeller.DataModelerAssert) Paths(org.uberfire.backend.server.util.Paths) Generated(javax.annotation.Generated) Matcher(java.util.regex.Matcher) Roaster(org.jboss.forge.roaster.Roaster) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) SequenceGenerator(javax.persistence.SequenceGenerator) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) JavaEnum(org.kie.workbench.common.services.datamodeller.core.JavaEnum) URI(java.net.URI) Instance(javax.enterprise.inject.Instance) Entity(javax.persistence.Entity) ParameterImpl(org.kie.workbench.common.services.datamodeller.core.impl.ParameterImpl) UniqueConstraint(javax.persistence.UniqueConstraint) ClassReactive(org.kie.api.definition.type.ClassReactive) JavaTypeInfo(org.kie.workbench.common.services.datamodeller.core.JavaTypeInfo) ENUM3(org.kie.workbench.common.services.datamodeller.annotations.ENUM3) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) List(java.util.List) AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) DataModelImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) Role(org.kie.api.definition.type.Role) JavaClassImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaClassImpl) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) Expires(org.kie.api.definition.type.Expires) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Parameter(org.kie.workbench.common.services.datamodeller.core.Parameter) Mock(org.mockito.Mock) Path(org.uberfire.java.nio.file.Path) RunWith(org.junit.runner.RunWith) DriverUtils(org.kie.workbench.common.services.datamodeller.util.DriverUtils) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) Type(org.kie.workbench.common.services.datamodeller.core.Type) ArrayList(java.util.ArrayList) Table(javax.persistence.Table) TypeSafe(org.kie.api.definition.type.TypeSafe) Duration(org.kie.api.definition.type.Duration) DataModel(org.kie.workbench.common.services.datamodeller.core.DataModel) Before(org.junit.Before) Logger(org.slf4j.Logger) JavaEnumImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaEnumImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) IOException(java.io.IOException) Test(org.junit.Test) Method(org.kie.workbench.common.services.datamodeller.core.Method) InputStreamReader(java.io.InputStreamReader) File(java.io.File) ImportImpl(org.kie.workbench.common.services.datamodeller.core.impl.ImportImpl) DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) MethodImpl(org.kie.workbench.common.services.datamodeller.core.impl.MethodImpl) Mockito(org.mockito.Mockito) TestEnums(org.kie.workbench.common.services.datamodeller.annotations.TestEnums) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Position(org.kie.api.definition.type.Position) JavaClass(org.kie.workbench.common.services.datamodeller.core.JavaClass) TypeImpl(org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) IOService(org.uberfire.io.IOService) BufferedReader(java.io.BufferedReader) Key(org.kie.api.definition.type.Key) Assert(org.junit.Assert) Collections(java.util.Collections) Visibility(org.kie.workbench.common.services.datamodeller.core.Visibility) InputStream(java.io.InputStream) TestAnnotation1(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation1) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) Method(org.kie.workbench.common.services.datamodeller.core.Method) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) IOException(java.io.IOException) Type(org.kie.workbench.common.services.datamodeller.core.Type) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) ParameterImpl(org.kie.workbench.common.services.datamodeller.core.impl.ParameterImpl) Parameter(org.kie.workbench.common.services.datamodeller.core.Parameter) List(java.util.List) ArrayList(java.util.ArrayList) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) TypeImpl(org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl) Test(org.junit.Test)

Example 3 with UpdateInfo

use of org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo in project kie-wb-common by kiegroup.

the class DataModelerServiceImpl method updateJavaClassSource.

private void updateJavaClassSource(DataObject dataObject, JavaClassSource javaClassSource, Map<String, String> renames, List<String> deletions, ClassTypeResolver classTypeResolver) throws Exception {
    if (javaClassSource == null || !javaClassSource.isClass()) {
        logger.warn("A null javaClassSource or javaClassSouce is not a Class, no processing will be done. javaClassSource: " + javaClassSource + " className: " + (javaClassSource != null ? javaClassSource.getName() : null));
        return;
    }
    JavaRoasterModelDriver modelDriver = new JavaRoasterModelDriver(filterHolder);
    UpdateInfo updateInfo = new UpdateInfo();
    if (renames != null) {
        for (Map.Entry<String, String> entry : renames.entrySet()) {
            updateInfo.addClassRename(entry.getKey(), entry.getValue());
        }
    }
    if (deletions != null) {
        for (String deletion : deletions) {
            updateInfo.addDeletedClass(deletion);
        }
    }
    modelDriver.updateSource(javaClassSource, dataObject, updateInfo, classTypeResolver);
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo)

Example 4 with UpdateInfo

use of org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriverTest method nestedClassUpdateTest.

@Test
public void nestedClassUpdateTest() {
    try {
        // First read the NestedClassUpdateTest
        Path nestedClassUpdateTestFilePath = rootPath.resolve("package5").resolve("NestedClassUpdateTest.java");
        String source = ioService.readAllString(nestedClassUpdateTestFilePath);
        JavaClassSource nestedClassUpdateTestJavaClassSource = (JavaClassSource) Roaster.parse(source);
        ClassLoader classLoader = getClass().getClassLoader();
        ClassTypeResolver classTypeResolver = DriverUtils.createClassTypeResolver(nestedClassUpdateTestJavaClassSource, classLoader);
        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, classLoader, filterHolder);
        ModelDriverResult result = javaRoasterModelDriver.loadDataObject(source, nestedClassUpdateTestFilePath);
        // 1) read the NestedClassUpdateTest
        DataObject nestedClassUpdateTest = result.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package5.NestedClassUpdateTest");
        // 2) modify the NestedClassUpdateTest according to the expected result
        JavaClass nestedClass = nestedClassUpdateTest.getNestedClasses().stream().filter(t -> t.getName().equals("NestedClass")).findFirst().get();
        assertNotNull(nestedClass);
        nestedClass.setName("UpdatedNestedClass");
        String removedInterface = nestedClass.removeInterface("ParametrizedInterface<Integer>");
        assertNotNull(removedInterface);
        nestedClass.addInterface("ParametrizedInterface<Double>");
        Method method = nestedClass.getMethod("method", Collections.EMPTY_LIST);
        assertNotNull(method);
        method.setName("updatedMethod");
        nestedClassUpdateTest.setName("NestedClassUpdateTestResult");
        // 3) compare the modified data object with the expected data object.
        Path expectedFilePath = rootPath.resolve("package5").resolve("NestedClassUpdateTestResult.java");
        String expectedSource = ioService.readAllString(expectedFilePath);
        JavaClassSource expectedJavaClassSource = (JavaClassSource) Roaster.parse(expectedSource);
        ModelDriverResult expectedResult = javaRoasterModelDriver.loadDataObject(expectedSource, expectedFilePath);
        DataObject nestedClassUpdateTestResult = expectedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package5.NestedClassUpdateTestResult");
        // First check, the modified data object in memory should be the same as the readed from the model.
        DataModelerAssert.assertEqualsDataObject(nestedClassUpdateTestResult, nestedClassUpdateTest);
        // Second check, update the JavaClassSource corresponding to the NestedClassUpdateTest
        javaRoasterModelDriver.updateSource(nestedClassUpdateTestJavaClassSource, nestedClassUpdateTest, new UpdateInfo(), classTypeResolver);
        ModelDriverResult updatedResult = javaRoasterModelDriver.loadDataObject(nestedClassUpdateTestJavaClassSource.toString(), nestedClassUpdateTestFilePath);
        // and now compare the updatedResult with the expected value.
        DataModelerAssert.assertEqualsDataObject(nestedClassUpdateTestResult, updatedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package5.NestedClassUpdateTestResult"));
        logger.debug(nestedClassUpdateTestJavaClassSource.toString());
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test failed: " + e.getMessage());
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) Description(org.kie.api.definition.type.Description) Arrays(java.util.Arrays) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) Timestamp(org.kie.api.definition.type.Timestamp) Label(org.kie.api.definition.type.Label) TestAnnotation1(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation1) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) LoggerFactory(org.slf4j.LoggerFactory) DataModelerAssert(org.kie.workbench.common.services.datamodeller.DataModelerAssert) Paths(org.uberfire.backend.server.util.Paths) Generated(javax.annotation.Generated) Matcher(java.util.regex.Matcher) Roaster(org.jboss.forge.roaster.Roaster) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) SequenceGenerator(javax.persistence.SequenceGenerator) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) JavaEnum(org.kie.workbench.common.services.datamodeller.core.JavaEnum) URI(java.net.URI) Instance(javax.enterprise.inject.Instance) Entity(javax.persistence.Entity) ParameterImpl(org.kie.workbench.common.services.datamodeller.core.impl.ParameterImpl) UniqueConstraint(javax.persistence.UniqueConstraint) ClassReactive(org.kie.api.definition.type.ClassReactive) JavaTypeInfo(org.kie.workbench.common.services.datamodeller.core.JavaTypeInfo) ENUM3(org.kie.workbench.common.services.datamodeller.annotations.ENUM3) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) List(java.util.List) AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) DataModelImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) Role(org.kie.api.definition.type.Role) JavaClassImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaClassImpl) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) Expires(org.kie.api.definition.type.Expires) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Parameter(org.kie.workbench.common.services.datamodeller.core.Parameter) Mock(org.mockito.Mock) Path(org.uberfire.java.nio.file.Path) RunWith(org.junit.runner.RunWith) DriverUtils(org.kie.workbench.common.services.datamodeller.util.DriverUtils) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) Type(org.kie.workbench.common.services.datamodeller.core.Type) ArrayList(java.util.ArrayList) Table(javax.persistence.Table) TypeSafe(org.kie.api.definition.type.TypeSafe) Duration(org.kie.api.definition.type.Duration) DataModel(org.kie.workbench.common.services.datamodeller.core.DataModel) Before(org.junit.Before) Logger(org.slf4j.Logger) JavaEnumImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaEnumImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) IOException(java.io.IOException) Test(org.junit.Test) Method(org.kie.workbench.common.services.datamodeller.core.Method) InputStreamReader(java.io.InputStreamReader) File(java.io.File) ImportImpl(org.kie.workbench.common.services.datamodeller.core.impl.ImportImpl) DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) MethodImpl(org.kie.workbench.common.services.datamodeller.core.impl.MethodImpl) Mockito(org.mockito.Mockito) TestEnums(org.kie.workbench.common.services.datamodeller.annotations.TestEnums) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Position(org.kie.api.definition.type.Position) JavaClass(org.kie.workbench.common.services.datamodeller.core.JavaClass) TypeImpl(org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) IOService(org.uberfire.io.IOService) BufferedReader(java.io.BufferedReader) Key(org.kie.api.definition.type.Key) Assert(org.junit.Assert) Collections(java.util.Collections) Visibility(org.kie.workbench.common.services.datamodeller.core.Visibility) InputStream(java.io.InputStream) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) Method(org.kie.workbench.common.services.datamodeller.core.Method) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) IOException(java.io.IOException) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) JavaClass(org.kie.workbench.common.services.datamodeller.core.JavaClass) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) Test(org.junit.Test)

Example 5 with UpdateInfo

use of org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriverTest method updateAnnotationsTest.

@Test
public void updateAnnotationsTest() {
    try {
        // First read the AnnotationsUpdateTest
        Path annotationsUpdateTestFilePath = rootPath.resolve("package3").resolve("AnnotationsUpdateTest.java");
        String source = ioService.readAllString(annotationsUpdateTestFilePath);
        JavaClassSource annotationsUpdateTestJavaClassSource = (JavaClassSource) Roaster.parse(source);
        ClassLoader classLoader = getClass().getClassLoader();
        ClassTypeResolver classTypeResolver = DriverUtils.createClassTypeResolver(annotationsUpdateTestJavaClassSource, classLoader);
        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, classLoader, filterHolder);
        ModelDriverResult result = javaRoasterModelDriver.loadDataObject(source, annotationsUpdateTestFilePath);
        // 1) read the AnnotationsUpdateTest
        DataObject annotationsUpdateTest = result.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package3.AnnotationsUpdateTest");
        // 2) modify the AnnotationsUpdateTest according to the expected result, basically updating all the needed annotations.
        // update the AnnotationValuesAnnotation
        Annotation annotationValuesAnnotation = annotationsUpdateTest.getAnnotation(AnnotationValuesAnnotation.class.getName());
        // 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);
        // update the ClassAnnotation
        Annotation classAnnotation = createAnnotation(ClassAnnotation.class);
        classAnnotation.setValue("classParam", "java.util.Collection.class");
        classAnnotation.setValue("classArrayParam", createArrayParam("List.class"));
        annotationsUpdateTest.addAnnotation(classAnnotation);
        // update the EnumsAnnotation
        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));
        annotationsUpdateTest.addAnnotation(enumsAnnotation);
        // update the PrimitivesAnnotation
        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", "{3,4}" );
        primitivesAnnotation.setValue("shortArrayParam", createArrayParam((short) 3, (short) 4));
        primitivesAnnotation.setValue("stringParam", "2");
        primitivesAnnotation.setValue("stringArrayParam", createArrayParam("3", "4"));
        annotationsUpdateTest.addAnnotation(primitivesAnnotation);
        // add the MarkerAnnotation
        annotationsUpdateTest.addAnnotation(createMarkerAnnotation());
        annotationsUpdateTest.setName("AnnotationsUpdateTestResult");
        // 3) compare the modified data object with the expected data object.
        Path expectedFilePath = rootPath.resolve("package3").resolve("AnnotationsUpdateTestResult.java");
        String expectedSource = ioService.readAllString(expectedFilePath);
        JavaClassSource expectedJavaClassSource = (JavaClassSource) Roaster.parse(expectedSource);
        ModelDriverResult expectedResult = javaRoasterModelDriver.loadDataObject(expectedSource, expectedFilePath);
        DataObject annotationsUpdateTestResult = expectedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package3.AnnotationsUpdateTestResult");
        // First check, the modified data object in memory should be the same as the readed from the model.
        DataModelerAssert.assertEqualsDataObject(annotationsUpdateTestResult, annotationsUpdateTest);
        // Second check, update the JavaClassSource corresponding to the AnnotationsUpdateTest
        javaRoasterModelDriver.updateSource(annotationsUpdateTestJavaClassSource, annotationsUpdateTest, new UpdateInfo(), classTypeResolver);
        ModelDriverResult updatedResult = javaRoasterModelDriver.loadDataObject(annotationsUpdateTestJavaClassSource.toString(), annotationsUpdateTestFilePath);
        // and now compare the updatedResult with the expected value.
        DataModelerAssert.assertEqualsDataObject(annotationsUpdateTestResult, updatedResult.getDataModel().getDataObject("org.kie.workbench.common.services.datamodeller.driver.package3.AnnotationsUpdateTestResult"));
        logger.debug(annotationsUpdateTestJavaClassSource.toString());
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test failed: " + e.getMessage());
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) Description(org.kie.api.definition.type.Description) Arrays(java.util.Arrays) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) Timestamp(org.kie.api.definition.type.Timestamp) Label(org.kie.api.definition.type.Label) TestAnnotation1(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation1) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) LoggerFactory(org.slf4j.LoggerFactory) DataModelerAssert(org.kie.workbench.common.services.datamodeller.DataModelerAssert) Paths(org.uberfire.backend.server.util.Paths) Generated(javax.annotation.Generated) Matcher(java.util.regex.Matcher) Roaster(org.jboss.forge.roaster.Roaster) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) SequenceGenerator(javax.persistence.SequenceGenerator) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) JavaEnum(org.kie.workbench.common.services.datamodeller.core.JavaEnum) URI(java.net.URI) Instance(javax.enterprise.inject.Instance) Entity(javax.persistence.Entity) ParameterImpl(org.kie.workbench.common.services.datamodeller.core.impl.ParameterImpl) UniqueConstraint(javax.persistence.UniqueConstraint) ClassReactive(org.kie.api.definition.type.ClassReactive) JavaTypeInfo(org.kie.workbench.common.services.datamodeller.core.JavaTypeInfo) ENUM3(org.kie.workbench.common.services.datamodeller.annotations.ENUM3) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) List(java.util.List) AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) DataModelImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataModelImpl) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) Role(org.kie.api.definition.type.Role) JavaClassImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaClassImpl) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) Expires(org.kie.api.definition.type.Expires) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Parameter(org.kie.workbench.common.services.datamodeller.core.Parameter) Mock(org.mockito.Mock) Path(org.uberfire.java.nio.file.Path) RunWith(org.junit.runner.RunWith) DriverUtils(org.kie.workbench.common.services.datamodeller.util.DriverUtils) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) Type(org.kie.workbench.common.services.datamodeller.core.Type) ArrayList(java.util.ArrayList) Table(javax.persistence.Table) TypeSafe(org.kie.api.definition.type.TypeSafe) Duration(org.kie.api.definition.type.Duration) DataModel(org.kie.workbench.common.services.datamodeller.core.DataModel) Before(org.junit.Before) Logger(org.slf4j.Logger) JavaEnumImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaEnumImpl) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) IOException(java.io.IOException) Test(org.junit.Test) Method(org.kie.workbench.common.services.datamodeller.core.Method) InputStreamReader(java.io.InputStreamReader) File(java.io.File) ImportImpl(org.kie.workbench.common.services.datamodeller.core.impl.ImportImpl) DataObjectImpl(org.kie.workbench.common.services.datamodeller.core.impl.DataObjectImpl) MethodImpl(org.kie.workbench.common.services.datamodeller.core.impl.MethodImpl) Mockito(org.mockito.Mockito) TestEnums(org.kie.workbench.common.services.datamodeller.annotations.TestEnums) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Position(org.kie.api.definition.type.Position) JavaClass(org.kie.workbench.common.services.datamodeller.core.JavaClass) TypeImpl(org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) IOService(org.uberfire.io.IOService) BufferedReader(java.io.BufferedReader) Key(org.kie.api.definition.type.Key) Assert(org.junit.Assert) Collections(java.util.Collections) Visibility(org.kie.workbench.common.services.datamodeller.core.Visibility) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) JavaClassSource(org.jboss.forge.roaster.model.source.JavaClassSource) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) IOException(java.io.IOException) DataObject(org.kie.workbench.common.services.datamodeller.core.DataObject) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) ClassTypeResolver(org.kie.soup.project.datamodel.commons.types.ClassTypeResolver) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) UpdateInfo(org.kie.workbench.common.services.datamodeller.driver.impl.UpdateInfo) Test(org.junit.Test)

Aggregations

BufferedReader (java.io.BufferedReader)4 File (java.io.File)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 InputStreamReader (java.io.InputStreamReader)4 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 List (java.util.List)4 Matcher (java.util.regex.Matcher)4 Generated (javax.annotation.Generated)4 Instance (javax.enterprise.inject.Instance)4 Entity (javax.persistence.Entity)4 SequenceGenerator (javax.persistence.SequenceGenerator)4 Table (javax.persistence.Table)4 UniqueConstraint (javax.persistence.UniqueConstraint)4 Roaster (org.jboss.forge.roaster.Roaster)4 JavaClassSource (org.jboss.forge.roaster.model.source.JavaClassSource)4 Assert (org.junit.Assert)4