use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method testSetupExamples_ProjectCopy.
@Test
public void testSetupExamples_ProjectCopy() {
final ExampleOrganizationalUnit exOU = mock(ExampleOrganizationalUnit.class);
final ExampleProject exProject1 = mock(ExampleProject.class);
doReturn("project 1").when(exProject1).getName();
final ExampleProject exProject2 = mock(ExampleProject.class);
doReturn("project 2").when(exProject1).getName();
final List<ExampleProject> exProjects = new ArrayList<ExampleProject>() {
{
add(exProject1);
add(exProject2);
}
};
final OrganizationalUnit ou = mock(OrganizationalUnit.class);
doReturn("ou").when(ou).getName();
final GitRepository repository1 = mock(GitRepository.class);
final Path repositoryRoot = mock(Path.class);
final Path module1Root = mock(Path.class);
final Path module2Root = mock(Path.class);
when(exOU.getName()).thenReturn("ou");
when(exProject1.getName()).thenReturn("module1");
when(exProject1.getRoot()).thenReturn(module1Root);
when(exProject2.getName()).thenReturn("module2");
when(exProject2.getRoot()).thenReturn(module2Root);
when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
final Optional<Branch> master = Optional.of(new Branch("master", PathFactory.newPath("testFile", "file:///")));
when(repository1.getDefaultBranch()).thenReturn(master);
when(repositoryRoot.toURI()).thenReturn("default:///");
when(module1Root.toURI()).thenReturn("default:///module1");
when(module2Root.toURI()).thenReturn("default:///module2");
when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
doReturn(repository1).when(repositoryCopier).copy(eq(ou), anyString(), eq(module1Root));
doReturn(repository1).when(repositoryCopier).copy(eq(ou), anyString(), eq(module2Root));
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn("project").when(project).getName();
doReturn(project).when(projectService).resolveProject(repository1);
final WorkspaceProjectContextChangeEvent event = service.setupExamples(exOU, exProjects);
assertNull(event.getOrganizationalUnit());
assertEquals(project, event.getWorkspaceProject());
verify(ouService, never()).createOrganizationalUnit(eq("ou"), eq(""), eq(""));
verify(repositoryCopier, times(2)).copy(eq(ou), anyString(), any(Path.class));
verify(newProjectEvent, times(2)).fire(any(NewProjectEvent.class));
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class AddProjectPopUpPresenter method createProject.
private void createProject(final DeploymentMode mode) {
view.showBusyIndicator(view.getSavingMessage());
final String name = view.getName();
final String description = view.getDescription();
final String groupId = view.getGroupId();
final String artifactId = view.getArtifactId();
final String version = view.getVersion();
validateFields(name, groupId, artifactId, version, () -> {
final RemoteCallback<WorkspaceProject> successCallback = getSuccessCallback();
final ErrorCallback<?> errorCallback = getErrorCallback();
if (view.isAdvancedOptionsSelected()) {
final POM pom = new POM(new GAV(groupId, artifactId, version));
pom.setName(name);
pom.setDescription(description);
libraryService.call(successCallback, errorCallback).createProject(projectContext.getActiveOrganizationalUnit().orElseThrow(() -> new IllegalStateException("Cannot create new project without an active organizational unit.")), pom, mode);
} else {
libraryService.call(successCallback, errorCallback).createProject(name, projectContext.getActiveOrganizationalUnit().orElseThrow(() -> new IllegalStateException("Cannot create new project without an active organizational unit.")), description, mode);
}
});
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class AssetsScreenTest method setUp.
@Before
public void setUp() {
WorkspaceProject projectInfo = mock(WorkspaceProject.class);
when(libraryPlaces.getActiveWorkspaceContext()).thenReturn(projectInfo);
EmptyAssetsView emptyView = mock(EmptyAssetsView.class);
PopulatedAssetsView populatedView = mock(PopulatedAssetsView.class);
HTMLElement emptyElement = mock(HTMLElement.class);
HTMLElement populatedElement = mock(HTMLElement.class);
when(emptyAssetsScreen.getView()).thenReturn(emptyView);
when(emptyView.getElement()).thenReturn(emptyElement);
when(populatedAssetsScreen.getView()).thenReturn(populatedView);
when(populatedView.getElement()).thenReturn(populatedElement);
this.assetsScreen = new AssetsScreen(view, libraryPlaces, emptyAssetsScreen, populatedAssetsScreen, ts, busyIndicatorView, new CallerMock<>(libraryService));
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method importDefaultProjectTest.
@Test
public void importDefaultProjectTest() {
final Repository repository = mock(Repository.class);
when(repository.getAlias()).thenReturn("example");
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
when(organizationalUnit.getName()).thenReturn("ou");
when(organizationalUnit.getIdentifier()).thenReturn("ou");
when(organizationalUnit.getRepositories()).thenReturn(singletonList(repository));
when(ouService.getOrganizationalUnits()).thenReturn(singletonList(organizationalUnit));
final ExampleProject exampleProject = mock(ExampleProject.class);
doReturn("example").when(exampleProject).getName();
final WorkspaceProject project = mock(WorkspaceProject.class);
final Module module = mock(Module.class);
doReturn(module).when(project).getMainModule();
final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
assertEquals(module, importedProject.getMainModule());
verify(examplesService).setupExamples(new ExampleOrganizationalUnit(organizationalUnit.getName()), singletonList(exampleProject));
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method queryingUnindexedProjectGivesUnindexedResult.
@Test
public void queryingUnindexedProjectGivesUnindexedResult() throws Exception {
Branch branch = new Branch("fake-branch", mockPath("default:///a/b/c"));
final WorkspaceProject project = new WorkspaceProject(ou1, repo1, branch, mock(Module.class));
when(indexOracle.isIndexed(project)).thenReturn(false);
when(ioService.exists(any())).thenReturn(true);
final ProjectAssetsQuery query = new ProjectAssetsQuery(project, "", 0, 10, Collections.emptyList());
AssetQueryResult result = libraryService.getProjectAssets(query);
assertEquals(ResultType.Unindexed, result.getResultType());
assertFalse(result.getAssetInfos().isPresent());
}
Aggregations