Search in sources :

Example 46 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class ProjectScreenServiceImplTest method testCopy.

@Test
public void testCopy() throws Exception {
    when(projectService.createFreshProjectName(any(), any())).thenCallRealMethod();
    doReturn(Arrays.asList(mock(WorkspaceProject.class))).when(projectService).getAllWorkspaceProjectsByName(any(), eq("newName"), anyBoolean());
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    final Path projectRoot = mock(Path.class);
    doReturn(ou).when(project).getOrganizationalUnit();
    doReturn(projectRoot).when(project).getRootPath();
    final Repository newRepository = mock(Repository.class);
    final Path newRepositoryRoot = PathFactory.newPath("root", "file:///root");
    doReturn(Optional.of(new Branch("main", newRepositoryRoot))).when(newRepository).getDefaultBranch();
    doReturn(newRepository).when(repositoryCopier).copy(ou, "newName", projectRoot);
    final ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
    final POM pom = new POM();
    doReturn(pom).when(pomService).load(any(Path.class));
    final Metadata metadata = mock(Metadata.class);
    doReturn(metadata).when(metadataService).getMetadata(any(Path.class));
    service.copy(project, "newName");
    verify(pomService).save(any(Path.class), pomArgumentCaptor.capture(), eq(metadata), eq("Renaming the project."), eq(true));
    final POM updatedPom = pomArgumentCaptor.getValue();
    assertEquals("newName-1", updatedPom.getName());
    assertEquals("newName", updatedPom.getGav().getArtifactId());
    verify(newProjectEvent).fire(any());
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) MavenRepositoryMetadata(org.guvnor.common.services.project.model.MavenRepositoryMetadata) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 47 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class ProjectScreenModelLoaderTest method testAllowList.

@Test
public void testAllowList() throws Exception {
    final AllowList allowList = new AllowList();
    when(allowListService.load(packageNamesAllowListPath)).thenReturn(allowList);
    final Metadata metadata = new Metadata();
    when(metadataService.getMetadata(packageNamesAllowListPath)).thenReturn(metadata);
    ProjectScreenModel model = loader.load(pathToPom);
    assertEquals(packageNamesAllowListPath, model.getPathToAllowList());
    assertEquals(allowList, model.getAllowList());
    assertEquals(metadata, model.getAllowListMetaData());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) AllowList(org.kie.workbench.common.services.shared.allowlist.AllowList) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 48 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class OverviewWidgetPresenterTest method testAddingDescription.

@Test
public void testAddingDescription() throws Exception {
    Metadata metadata = new Metadata();
    overview.setMetadata(metadata);
    ObservablePath observablePath = mock(ObservablePath.class);
    editor.setContent(overview, observablePath);
    presenter.onDescriptionEdited("Hello");
    assertEquals("Hello", overview.getMetadata().getDescription());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 49 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class OverviewWidgetPresenterTest method testDirty.

@Test
public void testDirty() throws Exception {
    Metadata metadata = new Metadata();
    overview.setMetadata(metadata);
    ObservablePath observablePath = mock(ObservablePath.class);
    editor.setContent(overview, observablePath);
    assertFalse(editor.isDirty());
    presenter.onDescriptionEdited("Hello");
    assertTrue(editor.isDirty());
    editor.resetDirty();
    assertFalse(editor.isDirty());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 50 with Metadata

use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.

the class DiscussionWidgetPresenterTest method testAddComment.

@Test
public void testAddComment() throws Exception {
    ArgumentCaptor<DiscussionRecord> discussionRecordArgumentCaptor = ArgumentCaptor.forClass(DiscussionRecord.class);
    when(identity.getIdentifier()).thenReturn("Toni");
    DiscussionWidgetPresenter presenterImpl = new DiscussionWidgetPresenter(view, identity, appConfigService);
    DiscussionWidgetView.Presenter presenter = presenterImpl;
    Metadata metadata = spy(new Metadata());
    Path path = mock(Path.class);
    when(metadata.getPath()).thenReturn(path);
    presenterImpl.setContent(metadata);
    presenter.onAddComment("Hello World!");
    verify(view).addRow(discussionRecordArgumentCaptor.capture());
    DiscussionRecord line = discussionRecordArgumentCaptor.getValue();
    assertNotNull(line);
    assertEquals(line.getTimestamp(), new Long(1234));
    assertEquals(line.getAuthor(), "Toni");
    assertEquals(line.getNote(), "Hello World!");
}
Also used : DiscussionWidgetView(org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetView) Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) DiscussionRecord(org.guvnor.common.services.shared.metadata.model.DiscussionRecord) DiscussionWidgetPresenter(org.kie.workbench.common.widgets.client.discussion.DiscussionWidgetPresenter) 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