use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class ProjectScreenTestBase method createProject.
protected WorkspaceProject createProject() {
final Path rootPath = mock(Path.class);
doReturn("git://modulePath").when(rootPath).toURI();
final Module module = mock(Module.class);
doReturn("mainModuleName").when(module).getModuleName();
doReturn("modulePath").when(module).getIdentifier();
doReturn(rootPath).when(module).getRootPath();
final Path pomPath = mock(Path.class);
doReturn(pomPath).when(module).getPomXMLPath();
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
final Repository repository = mock(Repository.class);
final Path repositoryRootPath = mock(Path.class);
doReturn(Optional.of(new Branch("master", repositoryRootPath))).when(repository).getDefaultBranch();
doReturn("rootpath").when(repositoryRootPath).toURI();
return new WorkspaceProject(organizationalUnit, repository, new Branch("master", mock(Path.class)), module);
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class LibraryToolbarPresenterTest method activeProjectHasOnlyOneBranch.
@Test
public void activeProjectHasOnlyOneBranch() throws Exception {
final Repository repository = mock(Repository.class);
final ArrayList<Branch> branches = new ArrayList<>();
branches.add(new Branch());
doReturn(branches).when(repository).getBranches();
doReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(KieModule.class)))).when(projectContext).getActiveWorkspaceProject();
presenter.setUpBranches();
verify(view).clearBranches();
verify(view).setBranchSelectorVisibility(false);
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class LibraryToolbarPresenterTest method listBranches.
@Test
public void listBranches() throws Exception {
final Repository repository = mock(Repository.class);
final ArrayList<Branch> branches = new ArrayList<>();
branches.add(new Branch("one", mock(Path.class)));
branches.add(new Branch("two", mock(Path.class)));
doReturn(branches).when(repository).getBranches();
// Normally this is in the branch list, but I want to verify it gets set from the branch in the project
final Branch selectedBranch = new Branch("selectedBranch", mock(Path.class));
doReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, selectedBranch, mock(KieModule.class)))).when(projectContext).getActiveWorkspaceProject();
presenter.setUpBranches();
verify(view).addBranch("one");
verify(view).addBranch("two");
view.setSelectedBranch("selectedBranch");
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class ProjectScreenServiceImpl method copy.
@Override
public void copy(final WorkspaceProject project, final String newName) {
final Repository copy = repositoryCopier.copy(project.getOrganizationalUnit(), newName, project.getRootPath());
if (!copy.getDefaultBranch().isPresent()) {
throw new IllegalStateException("Copy should have at least one branch.");
}
final Path newPomPath = Paths.convert(Paths.convert(copy.getDefaultBranch().get().getPath()).resolve("pom.xml"));
final POM pom = pomService.load(newPomPath);
if (pom != null) {
pom.setName(newName);
pom.getGav().setArtifactId(newName);
pomService.save(newPomPath, pom, metadataService.getMetadata(newPomPath), "Renaming the project.", true);
}
}
use of org.guvnor.structure.repositories.Repository 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());
}
Aggregations