Search in sources :

Example 6 with WhiteList

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

the class DependenciesPresenterTest method testRemoveAllFromWhiteList.

@Test
public void testRemoveAllFromWhiteList() {
    final Set<String> packages = new HashSet<>(Arrays.asList("foo", "bar"));
    dependenciesPresenter.model = mock(ProjectScreenModel.class);
    doReturn(new WhiteList(packages)).when(dependenciesPresenter.model).getWhiteList();
    assertEquals(2, dependenciesPresenter.model.getWhiteList().size());
    dependenciesPresenter.removeAllFromWhiteList(packages);
    assertEquals(0, dependenciesPresenter.model.getWhiteList().size());
    verify(enhancedDependenciesManager).update();
}
Also used : WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with WhiteList

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

the class DependenciesPresenterTest method testAddAllToWhiteList.

@Test
public void testAddAllToWhiteList() {
    dependenciesPresenter.model = mock(ProjectScreenModel.class);
    doReturn(new WhiteList()).when(dependenciesPresenter.model).getWhiteList();
    assertEquals(0, dependenciesPresenter.model.getWhiteList().size());
    dependenciesPresenter.addAllToWhiteList(new HashSet<>(Arrays.asList("foo", "bar")));
    assertEquals(2, dependenciesPresenter.model.getWhiteList().size());
    verify(enhancedDependenciesManager).update();
}
Also used : WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 8 with WhiteList

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

the class ProjectScreenModelLoaderTest method testWhiteList.

@Test
public void testWhiteList() throws Exception {
    final WhiteList whiteList = new WhiteList();
    when(whiteListService.load(packageNamesWhiteListPath)).thenReturn(whiteList);
    final Metadata metadata = new Metadata();
    when(metadataService.getMetadata(packageNamesWhiteListPath)).thenReturn(metadata);
    ProjectScreenModel model = loader.load(pathToPom);
    assertEquals(packageNamesWhiteListPath, model.getPathToWhiteList());
    assertEquals(whiteList, model.getWhiteList());
    assertEquals(metadata, model.getWhiteListMetaData());
}
Also used : WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 9 with WhiteList

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

the class ProjectScreenModelSaverTest method testWhiteListSave.

@Test
public void testWhiteListSave() throws Exception {
    final ProjectScreenModel model = new ProjectScreenModel();
    final WhiteList whiteList = new WhiteList();
    model.setWhiteList(whiteList);
    final Path pathToWhiteList = mock(Path.class);
    model.setPathToWhiteList(pathToWhiteList);
    final Metadata metadata = new Metadata();
    model.setWhiteListMetaData(metadata);
    saver.save(pathToPom, model, DeploymentMode.FORCED, "message white list");
    verify(whiteListService).save(eq(pathToWhiteList), eq(whiteList), eq(metadata), eq("message white list"));
}
Also used : Path(org.uberfire.backend.vfs.Path) WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 10 with WhiteList

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

the class PackageNameWhiteListFilter method getFilteredPackageNames.

/**
 * @return Package Names matching the White List to the available packages
 */
public WhiteList getFilteredPackageNames() {
    final WhiteList whiteList = new WhiteList();
    final Map<String, String> packageNamePatterns = getPatterns();
    for (String pattern : patterns) {
        for (Map.Entry<String, String> packageNamePath : packageNamePatterns.entrySet()) {
            if (ANT_PATH_MATCHER.match(pattern, packageNamePath.getValue())) {
                whiteList.add(packageNamePath.getKey());
            }
        }
    }
    return whiteList;
}
Also used : WhiteList(org.kie.workbench.common.services.shared.whitelist.WhiteList) Map(java.util.Map) HashMap(java.util.HashMap)

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