use of org.guvnor.common.services.project.model.WorkspaceProject 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.common.services.project.model.WorkspaceProject 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.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class ProjectScreenServiceImplTest method testSaveClashingGAVForced.
@Test()
public void testSaveClashingGAVForced() {
when(pathToPom.toURI()).thenReturn("default://p0/pom.xml");
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(pom);
model.setPOMMetaData(pomMetaData);
model.setPathToPOM(pathToPom);
model.setKModule(kmodule);
model.setKModuleMetaData(kmoduleMetaData);
model.setPathToKModule(pathToKieModule);
model.setProjectImports(projectImports);
model.setProjectImportsMetaData(projectImportsMetaData);
model.setPathToImports(pathToModuleImports);
model.setRepositories(moduleRepositories);
model.setPathToRepositories(pathToModuleRepositories);
final MavenRepositoryMetadata repositoryMetadata = new MavenRepositoryMetadata("id", "url", MavenRepositorySource.LOCAL);
moduleRepositories.getRepositories().add(new ModuleRepositories.ModuleRepository(true, repositoryMetadata));
when(repositoryResolver.getRepositoriesResolvingArtifact(eq(gav), eq(module), eq(repositoryMetadata))).thenReturn(new HashSet<MavenRepositoryMetadata>() {
{
add(repositoryMetadata);
}
});
final String comment = "comment";
final WorkspaceProject projectToBeReturned = new WorkspaceProject();
doReturn(projectToBeReturned).when(projectService).resolveProject(pathToPom);
try {
final WorkspaceProject project = service.save(pathToPom, model, comment, DeploymentMode.FORCED);
assertEquals(projectToBeReturned, project);
} catch (GAVAlreadyExistsException e) {
fail("Unexpected exception thrown: " + e.getMessage());
}
verify(pomService, times(1)).save(eq(pathToPom), eq(model.getPOM()), eq(pomMetaData), eq(comment));
verify(kModuleService, times(1)).save(eq(pathToKieModule), eq(kmodule), eq(kmoduleMetaData), eq(comment));
verify(importsService, times(1)).save(eq(pathToModuleImports), eq(projectImports), eq(projectImportsMetaData), eq(comment));
verify(repositoriesService, times(1)).save(eq(pathToModuleRepositories), eq(moduleRepositories), eq(comment));
}
use of org.guvnor.common.services.project.model.WorkspaceProject 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.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class BuildExecutorTest method mockWorkspaceProjectContext.
private void mockWorkspaceProjectContext(final POM pom, final Repository repository, final KieModule module, final Path pomPath) {
when(context.getActiveWorkspaceProject()).thenReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, new Branch("master", mock(Path.class)), module)));
when(repository.getAlias()).thenReturn("repository");
when(module.getModuleName()).thenReturn("module");
when(module.getPomXMLPath()).thenReturn(pomPath);
when(module.getPom()).thenReturn(pom);
when(module.getRootPath()).thenReturn(mock(Path.class));
when(pomPath.getFileName()).thenReturn("pom.xml");
when(context.getActiveModule()).thenReturn(Optional.of(module));
}
Aggregations