Search in sources :

Example 36 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 {
    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("master", 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", updatedPom.getName());
    assertEquals("newName", updatedPom.getGav().getArtifactId());
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) 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 37 with Metadata

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

the class PersistenceDescriptorEditorServiceImplTest method testSaveAndRename.

@Test
public void testSaveAndRename() throws Exception {
    final Path path = mock(Path.class);
    final Path expectedPath = mock(Path.class);
    final Metadata metadata = mock(Metadata.class);
    final PersistenceDescriptorEditorContent content = mock(PersistenceDescriptorEditorContent.class);
    final String newName = "newName";
    final String comment = "comment";
    doReturn(expectedPath).when(saveAndRenameService).saveAndRename(path, newName, metadata, content, comment);
    final Path actualPath = service.saveAndRename(path, newName, metadata, content, comment);
    verify(saveAndRenameService).saveAndRename(path, newName, metadata, content, comment);
    assertEquals(expectedPath, actualPath);
}
Also used : Path(org.uberfire.backend.vfs.Path) PersistenceDescriptorEditorContent(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Example 38 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)

Example 39 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 40 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)

Aggregations

Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)62 Test (org.junit.Test)45 Path (org.uberfire.backend.vfs.Path)35 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)13 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)9 Package (org.guvnor.common.services.project.model.Package)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 HashMap (java.util.HashMap)5 POM (org.guvnor.common.services.project.model.POM)5 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)5 ObservablePath (org.uberfire.backend.vfs.ObservablePath)5 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)5 Overview (org.guvnor.common.services.shared.metadata.model.Overview)4 WhiteList (org.kie.workbench.common.services.shared.whitelist.WhiteList)4 Map (java.util.Map)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 InvalidateDMOPackageCacheEvent (org.guvnor.common.services.project.builder.events.InvalidateDMOPackageCacheEvent)3 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)3 KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)3 Mockito.anyString (org.mockito.Mockito.anyString)3