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