use of org.guvnor.structure.organizationalunit.config.SpaceConfigStorage 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.guvnor.structure.organizationalunit.config.SpaceConfigStorage in project kie-wb-common by kiegroup.
the class MigrationRepositoryServiceImpl method removeRepositoryFromSpaceInfo.
private void removeRepositoryFromSpaceInfo(Repository repo) {
SpaceConfigStorage spaceConfigStorage = this.spaceConfigStorage.get(repo.getSpace().getName());
SpaceInfo spaceInfo = this.spaceConfigStorage.get(repo.getSpace().getName()).loadSpaceInfo();
spaceInfo.removeRepository(repo.getAlias());
spaceConfigStorage.saveSpaceInfo(spaceInfo);
}
use of org.guvnor.structure.organizationalunit.config.SpaceConfigStorage 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());
}
Aggregations