use of org.kie.workbench.common.services.shared.allowlist.AllowList in project kie-wb-common by kiegroup.
the class PackageNameAllowListSaverTest method testSave.
@Test
public void testSave() throws Exception {
final Path path = testFileSystem.createTempFile("allowlist");
final AllowList allowList = new AllowList();
allowList.add("org.drools");
allowList.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, allowList, metadata, comment);
ArgumentCaptor<String> allowListTextArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), allowListTextArgumentCaptor.capture(), eq(attributes), eq(commentedOption));
final String allowListAsText = allowListTextArgumentCaptor.getValue();
assertTrue(allowListAsText.contains("org.drools"));
assertTrue(allowListAsText.contains("org.guvnor"));
}
use of org.kie.workbench.common.services.shared.allowlist.AllowList in project kie-wb-common by kiegroup.
the class PackageNameAllowListServiceImplTest method ifAllowListIsEmptyAllowListEverything.
@Test
public void ifAllowListIsEmptyAllowListEverything() throws Exception {
final PackageNameAllowListService packageNameAllowListService = makeService("");
AllowList filterPackageNames = packageNameAllowListService.filterPackageNames(mock(KieModule.class), new ArrayList<String>() {
{
add("a");
add("b");
add("c");
}
});
assertEquals(3, filterPackageNames.size());
assertTrue(filterPackageNames.contains("a"));
assertTrue(filterPackageNames.contains("b"));
assertTrue(filterPackageNames.contains("c"));
}
use of org.kie.workbench.common.services.shared.allowlist.AllowList in project kie-wb-common by kiegroup.
the class PackageNameAllowListFilter method getFilteredPackageNames.
/**
* @return Package Names matching the Allow List to the available packages
*/
public AllowList getFilteredPackageNames() {
final AllowList allowList = new AllowList();
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())) {
allowList.add(packageNamePath.getKey());
}
}
}
return allowList;
}
use of org.kie.workbench.common.services.shared.allowlist.AllowList in project kie-wb-common by kiegroup.
the class DependenciesItemPresenterTest method testSetupTransitive.
@Test
public void testSetupTransitive() {
dependenciesItemPresenter.setup(new TransitiveEnhancedDependency(mock(Dependency.class), emptySet()), new AllowList(), mock(DependenciesPresenter.class));
verify(view).init(any());
verify(view).setGroupId(any());
verify(view).setArtifactId(any());
verify(view).setVersion(any());
verify(view).setPackagesAllowListedState(any());
verify(view).setTransitiveDependency(eq(true));
}
use of org.kie.workbench.common.services.shared.allowlist.AllowList in project kie-wb-common by kiegroup.
the class DependenciesPresenterTest method testRemoveAllFromAllowList.
@Test
public void testRemoveAllFromAllowList() {
final Set<String> packages = new HashSet<>(Arrays.asList("foo", "bar"));
dependenciesPresenter.model = mock(ProjectScreenModel.class);
doReturn(new AllowList(packages)).when(dependenciesPresenter.model).getAllowList();
assertEquals(2, dependenciesPresenter.model.getAllowList().size());
dependenciesPresenter.removeAllFromAllowList(packages);
assertEquals(0, dependenciesPresenter.model.getAllowList().size());
verify(enhancedDependenciesManager).update();
}
Aggregations