use of org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService in project kie-wb-common by kiegroup.
the class ProjectImportServiceImplRepositoryNamesTest method setup.
@Before
public void setup() {
service = spy(new ProjectImportServiceImpl(ioService, metadataService, repositoryFactory, moduleService, validators, pathUtil, projectService, projectScreenService, newProjectEvent, repoService, spaceConfigStorageRegistry));
when(spaceConfigStorageRegistry.get(anyString())).thenReturn(spaceConfigStorage);
when(spaceConfigStorageRegistry.getBatch(anyString())).thenReturn(new SpaceConfigStorageRegistryImpl.SpaceStorageBatchImpl(spaceConfigStorage));
when(spaceConfigStorageRegistry.exist(anyString())).thenReturn(true);
when(validators.getValidators()).thenReturn(new ArrayList<>());
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1GroupId"));
}
});
when(moduleService.resolveModule(any(Path.class))).thenAnswer((Answer<KieModule>) invocationOnMock -> {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
exProject1 = mock(ImportProject.class);
importProjects = Collections.singletonList(exProject1);
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);
when(organizationalUnit.getName()).thenReturn("ou");
when(organizationalUnit.getSpace()).thenReturn(space);
when(space.getName()).thenReturn("ou");
when(exProject1.getName()).thenReturn("module1");
when(exProject1.getRoot()).thenReturn(module1Root);
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(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
doReturn("module1").when(repository1).getAlias();
final WorkspaceProject project = spy(new WorkspaceProject());
doReturn(repository1.getAlias()).when(project).getName();
doReturn(mock(Module.class)).when(project).getMainModule();
doReturn(mock(OrganizationalUnit.class)).when(project).getOrganizationalUnit();
doReturn(project).when(projectService).resolveProject(repository1);
doReturn(project).when(projectService).resolveProject(any(Path.class));
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(new POM());
doReturn(model).when(projectScreenService).load(any());
}
use of org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService in project kie-wb-common by kiegroup.
the class ExamplesServiceImplTest method setup.
@Before
public void setup() throws Exception {
when(spaceConfigStorageRegistry.get(Mockito.<String>any())).thenReturn(spaceConfigStorage);
when(spaceConfigStorageRegistry.getBatch(Mockito.<String>any())).thenReturn(new SpaceConfigStorageRegistryImpl.SpaceStorageBatchImpl(spaceConfigStorage));
when(spaceConfigStorageRegistry.exist(Mockito.<String>any())).thenReturn(true);
when(ou.getSpace()).thenReturn(space);
when(space.getName()).thenReturn("ou");
service = spy(new ExamplesServiceImpl(ioService, repositoryFactory, moduleService, ouService, projectService, metadataService, newProjectEvent, projectScreenService, validators, spaceConfigStorageRegistry, systemFS, pathUtil, repositoryService));
FileUtils.deleteDirectory(new File(".kie-wb-playground"));
when(this.validators.getValidators()).thenReturn(new ArrayList<>());
doAnswer(invocationOnMock -> {
String spaceName = (String) invocationOnMock.getArguments()[0];
String defaultGroupId = (String) invocationOnMock.getArguments()[1];
OrganizationalUnitImpl o = new OrganizationalUnitImpl(spaceName, defaultGroupId);
organizationalUnits.put(spaceName, o);
return o;
}).when(ouService).createOrganizationalUnit(Mockito.<String>any(), Mockito.<String>any());
doAnswer(invocationOnMock -> organizationalUnits.get(invocationOnMock.getArguments()[0])).when(ouService).getOrganizationalUnit(Mockito.<String>any());
when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {
{
add(new OrganizationalUnitImpl("ou1Name", "ou1GroupId"));
add(new OrganizationalUnitImpl("ou2Name", "ou2GroupId"));
}
});
when(moduleService.resolveModule(Mockito.<Path>any())).thenAnswer((Answer<KieModule>) invocationOnMock -> {
final Path path = (Path) invocationOnMock.getArguments()[0];
final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
return module;
});
when(sessionInfo.getId()).thenReturn("sessionId");
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn("user");
doAnswer(invocationOnMock -> organizationalUnits.containsKey(invocationOnMock.getArguments()[0])).when(service).existSpace(any());
}
use of org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService in project kie-wb-common by kiegroup.
the class POMWizardPageTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
gavEditor = new GAVEditor(gavEditorView);
pomEditor = spy(new POMEditorPanel(pomEditorView, syncBeanManager, gavPreferences, projectScopedResolutionStrategySupplier));
// POMEditorView implementation updates a nested GAVEditor presenter. Mock the implementation to avoid use of real widgets
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
final String artifactId = (String) invocation.getArguments()[0];
gavEditor.setArtifactID(artifactId);
return null;
}
}).when(pomEditorView).setArtifactID(any());
// POMEditorView implementation updates a nested GAVEditor presenter. Mock the implementation to avoid use of real widgets
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
final GAV gav = (GAV) invocation.getArguments()[0];
gavEditor.setGAV(gav);
return null;
}
}).when(pomEditorView).setGAV(any());
// POMEditorView implementation updates a nested GAVEditor presenter. Mock the implementation to avoid use of real widgets
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
final ArtifactIdChangeHandler handler = (ArtifactIdChangeHandler) invocation.getArguments()[0];
gavEditor.addArtifactIdChangeHandler(handler);
return null;
}
}).when(pomEditorView).addArtifactIdChangeHandler(any());
page = spy(new POMWizardPage(pomEditor, view, event, new CallerMock<ProjectScreenService>(projectScreenService), new CallerMock<ValidationService>(validationService)));
page.initialise();
doAnswer(invocationOnMock -> {
((ParameterizedCommand<GAVPreferences>) invocationOnMock.getArguments()[1]).execute(gavPreferences);
return null;
}).when(gavPreferences).load(any(), any(), any());
}
use of org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService in project kie-wb-common by kiegroup.
the class ProjectScreen method getDuplicateCommand.
CommandWithFileNameAndCommitMessage getDuplicateCommand() {
return details -> {
copyPopUpPresenter.getView().hide();
view.showBusyIndicator(view.getLoadingMessage());
promises.promisify(projectScreenService, s -> {
s.copy(workspaceProject, details.getNewFileName());
}).then(i -> {
view.hideBusyIndicator();
notificationEvent.fire(new NotificationEvent(view.getItemSuccessfullyDuplicatedMessage(), NotificationEvent.NotificationType.SUCCESS));
return promises.resolve();
}).catch_(this::onError);
};
}
use of org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService in project kie-wb-common by kiegroup.
the class ProjectScreen method reimport.
public void reimport() {
projectController.canUpdateProject(workspaceProject).then(userCanUpdateProject -> {
if (userCanUpdateProject) {
final Path pomXMLPath = workspaceProject.getMainModule().getPomXMLPath();
view.showBusyIndicator(view.getLoadingMessage());
promises.promisify(projectScreenService, s -> {
s.reImport(pomXMLPath);
}).then(i -> {
view.hideBusyIndicator();
notificationEvent.fire(new NotificationEvent(view.getReimportSuccessfulMessage(), NotificationEvent.NotificationType.SUCCESS));
return promises.resolve();
}).catch_(this::onError);
}
return promises.resolve();
});
}
Aggregations