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