use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method testGetMetadataSupplier.
@Test
public void testGetMetadataSupplier() {
final GuidedDecisionTableView.Presenter document = mock(GuidedDecisionTableView.Presenter.class);
final Overview overview = mock(Overview.class);
final Metadata expectedMetadata = mock(Metadata.class);
doReturn(document).when(presenter).getActiveDocument();
doReturn(overview).when(document).getOverview();
doReturn(expectedMetadata).when(overview).getMetadata();
final Metadata actualMetadata = presenter.getMetadataSupplier().get();
assertEquals(expectedMetadata, actualMetadata);
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.
the class ProjectScreenModelTests method testHashCode.
@Test
public void testHashCode() {
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(new POM("test", "test", "url", new GAV("groupID", "artifactID", "version")));
final MavenRepository repository = new MavenRepository();
repository.setId("guvnor-m2-repo");
repository.setName("Guvnor M2 Repo");
repository.setUrl("http://localhost/maven2/");
model.getPOM().addRepository(repository);
model.setPOMMetaData(new Metadata());
model.setKModule(new KModuleModel());
model.setKModuleMetaData(new Metadata());
model.setProjectTagsMetaData(new Metadata());
model.setProjectImports(new ProjectImports());
model.setProjectImportsMetaData(new Metadata());
final int hashCode1 = model.hashCode();
assertTrue(hashCode1 <= Integer.MAX_VALUE);
assertTrue(hashCode1 >= Integer.MIN_VALUE);
model.getProjectImports().getImports().addImport(new Import("java.lang.List"));
final int hashCode2 = model.hashCode();
assertTrue(hashCode2 <= Integer.MAX_VALUE);
assertTrue(hashCode2 >= Integer.MIN_VALUE);
assertNotEquals(hashCode1, hashCode2);
}
use of org.guvnor.common.services.shared.metadata.model.Metadata 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());
}
use of org.guvnor.common.services.shared.metadata.model.Metadata 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"));
}
use of org.guvnor.common.services.shared.metadata.model.Metadata 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"));
}
Aggregations