Search in sources :

Example 66 with Metadata

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);
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Overview(org.guvnor.common.services.shared.metadata.model.Overview) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Test(org.junit.Test)

Example 67 with Metadata

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);
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) MavenRepository(org.guvnor.common.services.project.model.MavenRepository) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) GAV(org.guvnor.common.services.project.model.GAV) POM(org.guvnor.common.services.project.model.POM) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 68 with Metadata

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());
}
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 69 with Metadata

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"));
}
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 70 with Metadata

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"));
}
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

Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)75 Test (org.junit.Test)63 Path (org.uberfire.backend.vfs.Path)44 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)13 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)10 POM (org.guvnor.common.services.project.model.POM)8 HashMap (java.util.HashMap)6 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)6 ObservablePath (org.uberfire.backend.vfs.ObservablePath)6 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)5 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)5 GAV (org.guvnor.common.services.project.model.GAV)4 AllowList (org.kie.workbench.common.services.shared.allowlist.AllowList)4 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)4 Matchers.anyString (org.mockito.Matchers.anyString)4 Map (java.util.Map)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 WhiteList (org.kie.workbench.common.services.shared.whitelist.WhiteList)3