Search in sources :

Example 11 with WhiteList

use of org.kie.workbench.common.services.shared.whitelist.WhiteList 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 12 with WhiteList

use of org.kie.workbench.common.services.shared.whitelist.WhiteList in project kie-wb-common by kiegroup.

the class PackageNameWhiteListSaverTest method testSave.

@Test
public void testSave() throws Exception {
    final Path path = testFileSystem.createTempFile("whitelist");
    final WhiteList whiteList = new WhiteList();
    whiteList.add("org.drools");
    whiteList.add("org.guvnor");
    final Metadata metadata = new Metadata();
    final String comment = "comment";
    final HashMap<String, Object> attributes = new HashMap<String, Object>();
    when(metadataService.setUpAttributes(path, metadata)).thenReturn(attributes);
    final CommentedOption commentedOption = mock(CommentedOption.class);
    when(commentedOptionFactory.makeCommentedOption("comment")).thenReturn(commentedOption);
    saver.save(path, whiteList, metadata, comment);
    ArgumentCaptor<String> whiteListTextArgumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), whiteListTextArgumentCaptor.capture(), eq(attributes), eq(commentedOption));
    final String whiteListAsText = whiteListTextArgumentCaptor.getValue();
    assertTrue(whiteListAsText.contains("org.drools"));
    assertTrue(whiteListAsText.contains("org.guvnor"));
}
Also used : Path(org.uberfire.backend.vfs.Path) HashMap(java.util.HashMap) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Aggregations

WhiteList (org.kie.workbench.common.services.shared.whitelist.WhiteList)12 Test (org.junit.Test)11 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)5 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 Path (org.uberfire.backend.vfs.Path)3 HashMap (java.util.HashMap)2 PackageNameWhiteListService (org.kie.workbench.common.services.shared.whitelist.PackageNameWhiteListService)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 BuildMessage (org.guvnor.common.services.project.builder.model.BuildMessage)1 NormalEnhancedDependency (org.kie.workbench.common.services.shared.dependencies.NormalEnhancedDependency)1 TransitiveEnhancedDependency (org.kie.workbench.common.services.shared.dependencies.TransitiveEnhancedDependency)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)1