Search in sources :

Example 11 with BuildMessage

use of org.guvnor.common.services.project.builder.model.BuildMessage in project kie-wb-common by kiegroup.

the class BuilderTest method testBuilderKModuleHasDependency.

@Test
public void testBuilderKModuleHasDependency() throws Exception {
    URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2");
    SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    final BuildResults results = builder.build();
    // Debug output
    if (!results.getMessages().isEmpty()) {
        for (BuildMessage m : results.getMessages()) {
            logger.debug(m.getText());
        }
    }
    assertTrue(results.getMessages().isEmpty());
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Test(org.junit.Test)

Example 12 with BuildMessage

use of org.guvnor.common.services.project.builder.model.BuildMessage in project kie-wb-common by kiegroup.

the class BuilderTest method testBuilderKModuleHasDependencyMetaData.

@Test
public void testBuilderKModuleHasDependencyMetaData() throws Exception {
    URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2");
    SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    final BuildResults results = builder.build();
    // Debug output
    if (!results.getMessages().isEmpty()) {
        for (BuildMessage m : results.getMessages()) {
            logger.debug(m.getText());
        }
    }
    assertTrue(results.getMessages().isEmpty());
    final KieModuleMetaData metaData = KieModuleMetaData.Factory.newKieModuleMetaData(builder.getKieModule());
    // Check packages
    final Set<String> packageNames = new HashSet<>();
    final Iterator<String> packageNameIterator = metaData.getPackages().iterator();
    while (packageNameIterator.hasNext()) {
        packageNames.add(packageNameIterator.next());
    }
    assertEquals(2, packageNames.size());
    assertTrue(packageNames.contains("defaultpkg"));
    assertTrue(packageNames.contains("org.kie.workbench.common.services.builder.tests.test1"));
    // Check classes
    final String packageName = "org.kie.workbench.common.services.builder.tests.test1";
    assertEquals(1, metaData.getClasses(packageName).size());
    final String className = metaData.getClasses(packageName).iterator().next();
    assertEquals("Bean", className);
    // Check metadata
    final Class clazz = metaData.getClass(packageName, className);
    final TypeMetaInfo typeMetaInfo = metaData.getTypeMetaInfo(clazz);
    assertNotNull(typeMetaInfo);
    assertFalse(typeMetaInfo.isEvent());
}
Also used : BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) URL(java.net.URL) KieModuleMetaData(org.kie.scanner.KieModuleMetaData) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) TypeMetaInfo(org.drools.core.rule.TypeMetaInfo) Module(org.guvnor.common.services.project.model.Module) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with BuildMessage

use of org.guvnor.common.services.project.builder.model.BuildMessage in project kie-wb-common by kiegroup.

the class BuilderTest method testKModuleContainsXLS.

@Test
public void testKModuleContainsXLS() throws Exception {
    URL url = this.getClass().getResource("/ExampleWithExcel");
    SimpleFileSystemProvider p = new SimpleFileSystemProvider();
    org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
    final Module module = moduleService.resolveModule(Paths.convert(path));
    final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
    final BuildResults results = builder.build();
    // Debug output
    if (!results.getMessages().isEmpty()) {
        for (BuildMessage m : results.getMessages()) {
            logger.debug(m.getText());
        }
    }
    assertTrue(results.getMessages().isEmpty());
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildResults(org.guvnor.common.services.project.builder.model.BuildResults) Module(org.guvnor.common.services.project.model.Module) URL(java.net.URL) Test(org.junit.Test)

Example 14 with BuildMessage

use of org.guvnor.common.services.project.builder.model.BuildMessage in project kie-wb-common by kiegroup.

the class ClassVerifierTest method testVerifyClass.

@Test
public void testVerifyClass() {
    WhiteList whiteList = new WhiteList();
    whiteList.add("org.kie.workbench.common.services.backend.builder");
    ClassVerifier classVerifier = new ClassVerifier(kieModuleMetaData, typeSourceResolver);
    List<BuildMessage> messages = classVerifier.verify(whiteList);
    assertEquals(messages.size(), 1);
    assertEquals("Verification of class org.kie.workbench.common.services.backend.builder.SomeClass failed and will not be available for authoring.\n" + "Underlying system error is: The access to the class is not allowed. Please check the necessary external dependencies for this project are configured correctly.", messages.get(0).getText());
}
Also used : BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) Test(org.junit.Test)

Example 15 with BuildMessage

use of org.guvnor.common.services.project.builder.model.BuildMessage in project kie-wb-common by kiegroup.

the class MessageConverterTest method checkMessageWithoutKieBase.

@Test
public void checkMessageWithoutKieBase() {
    final Message m = new MessageImpl(ID, Message.Level.ERROR, FILE, TEXT);
    final BuildMessage bm = MessageConverter.convertMessage(m, handles);
    assertConversion(bm, () -> TEXT);
}
Also used : BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) BuildMessage(org.guvnor.common.services.project.builder.model.BuildMessage) Message(org.kie.api.builder.Message) MessageImpl(org.drools.compiler.kie.builder.impl.MessageImpl) Test(org.junit.Test)

Aggregations

BuildMessage (org.guvnor.common.services.project.builder.model.BuildMessage)15 Test (org.junit.Test)9 BuildResults (org.guvnor.common.services.project.builder.model.BuildResults)8 URL (java.net.URL)4 Module (org.guvnor.common.services.project.model.Module)4 SimpleFileSystemProvider (org.uberfire.java.nio.fs.file.SimpleFileSystemProvider)4 ArrayList (java.util.ArrayList)2 MessageImpl (org.drools.compiler.kie.builder.impl.MessageImpl)2 IncrementalBuildResults (org.guvnor.common.services.project.builder.model.IncrementalBuildResults)2 KieModule (org.kie.workbench.common.services.shared.project.KieModule)2 HashSet (java.util.HashSet)1 ContextNotActiveException (javax.enterprise.context.ContextNotActiveException)1 TypeMetaInfo (org.drools.core.rule.TypeMetaInfo)1 DeploymentMode (org.guvnor.common.services.project.service.DeploymentMode)1 Message (org.kie.api.builder.Message)1 KieModuleMetaData (org.kie.scanner.KieModuleMetaData)1 WhiteList (org.kie.workbench.common.services.shared.whitelist.WhiteList)1