use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class ProjectScreenTest method testContextModuleIsUpdatedSapshot.
@Test
public void testContextModuleIsUpdatedSapshot() {
final WorkspaceProject workspaceProject = mock(WorkspaceProject.class);
doReturn("module name").when(workspaceProject).getName();
final Module module = mock(Module.class);
when(module.getPom()).thenReturn(new POM(new GAV(GROUP_ID, ARTIFACT, VERSION + "-SNAPSHOT")));
when(workspaceProject.getMainModule()).thenReturn(module);
presenter.changeProjectAndTitleWhenContextChange(new WorkspaceProjectContextChangeEvent(workspaceProject));
verify(view).setTitle("module name");
verify(projectMainActions).setBuildEnabled(eq(false));
verify(projectMainActions).setDeployEnabled(eq(false));
verify(projectMainActions).setRedeployEnabled(eq(true));
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class LibraryPerspectiveTest method libraryResetsContextOnCloseTest.
@Test
public void libraryResetsContextOnCloseTest() {
perspective.onClose();
verify(projectContextChangeEvent).fire(new WorkspaceProjectContextChangeEvent());
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class LibraryPlaces method goToProject.
public void goToProject(final WorkspaceProject project) {
if (projectContext.getActiveWorkspaceProject().map(activeProject -> !activeProject.equals(project)).orElse(true)) {
final String lastBranch = cookie.get(getProjectLastBranchCookie(project.getName()));
cookie.set(getLastProjectCookie(), project.getName());
closeAllPlacesOrNothing(() -> {
projectContextChangeEvent.fire(new WorkspaceProjectContextChangeEvent(project, project.getMainModule()));
if (!lastBranch.equals("")) {
goToProject(project.getSpace().getName(), project.getName(), lastBranch);
} else {
goToProject(project, project.getBranch());
}
});
} else {
goToProject();
}
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class ProjectImportServiceImplTest method testImportProjects_ProjectImport.
@Test
public void testImportProjects_ProjectImport() {
final ImportProject exProject1 = mock(ImportProject.class);
final ImportProject exProject2 = mock(ImportProject.class);
final List<ImportProject> exProjects = Arrays.asList(exProject1, exProject2);
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(exProject1.getName()).thenReturn("project1");
when(exProject1.getRoot()).thenReturn(module1Root);
when(exProject2.getName()).thenReturn("project2");
when(exProject2.getRoot()).thenReturn(module2Root);
when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
final Optional<Branch> main = Optional.of(new Branch("main", PathFactory.newPath("testFile", "file:///")));
when(repository1.getDefaultBranch()).thenReturn(main);
when(repositoryRoot.toURI()).thenReturn("default:///");
when(module1Root.toURI()).thenReturn("default:///module1");
when(module2Root.toURI()).thenReturn("default:///module2");
when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(organizationalUnit);
WorkspaceProject project1 = mock(WorkspaceProject.class);
when(project1.getName()).thenReturn("project1");
when(project1.getBranch()).thenReturn(main.get());
WorkspaceProject project2 = mock(WorkspaceProject.class);
when(project2.getName()).thenReturn("project2");
when(project2.getBranch()).thenReturn(main.get());
doReturn(project1).when(service).importProject(eq(organizationalUnit), eq(exProject1));
doReturn(project2).when(service).importProject(eq(organizationalUnit), eq(exProject2));
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn("project").when(project).getName();
doReturn(project).when(projectService).resolveProject(repository1);
final WorkspaceProjectContextChangeEvent event = service.importProjects(organizationalUnit, exProjects);
assertEquals(organizationalUnit, event.getOrganizationalUnit());
assertEquals(null, event.getWorkspaceProject());
verify(ouService, never()).createOrganizationalUnit(eq("ou"), eq(""));
verify(service, times(2)).importProject(eq(organizationalUnit), any());
verify(spaceConfigStorage).startBatch();
verify(spaceConfigStorage).endBatch();
}
use of org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent in project kie-wb-common by kiegroup.
the class LibraryPlacesTest method goToOrganizationalUnitsTest.
@Test
public void goToOrganizationalUnitsTest() {
final PlaceRequest placeRequest = new DefaultPlaceRequest(LibraryPlaces.ORGANIZATIONAL_UNITS_SCREEN);
final PartDefinitionImpl part = new PartDefinitionImpl(placeRequest);
part.setSelectable(false);
libraryPlaces.goToOrganizationalUnits();
verify(projectContextChangeEvent).fire(projectContextChangeEventArgumentCaptor.capture());
assertNull(projectContextChangeEventArgumentCaptor.getValue().getOrganizationalUnit());
final ArgumentCaptor<WorkspaceProjectContextChangeEvent> eventArgumentCaptor = ArgumentCaptor.forClass(WorkspaceProjectContextChangeEvent.class);
verify(projectContextChangeEvent).fire(eventArgumentCaptor.capture());
final WorkspaceProjectContextChangeEvent event = eventArgumentCaptor.getValue();
assertNull(event.getOrganizationalUnit());
assertNull(event.getWorkspaceProject());
verify(placeManager).closeAllPlaces();
verify(placeManager).goTo(eq(part), Mockito.<PanelDefinition>any());
verify(libraryBreadcrumbs).setupForSpacesScreen();
}
Aggregations