use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class ModuleServiceImplNewModuleTest method testNewModuleCreationNonClashingGAV.
@Test
public void testNewModuleCreationNonClashingGAV() throws URISyntaxException {
final Repository repository = mock(Repository.class);
final Path masterBranchRoot = mock(Path.class);
doReturn(Optional.of(new Branch("master", masterBranchRoot))).when(repository).getDefaultBranch();
final POM pom = new POM();
final String baseURL = "/";
final KieModule expected = new KieModule();
when(saver.save(masterBranchRoot, pom, baseURL)).thenReturn(expected);
final Module project = moduleService.newModule(masterBranchRoot, pom, baseURL);
assertEquals(expected, project);
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class ModuleServiceImplNewModuleTest method testNewModuleCreationClashingGAV.
@Test(expected = GAVAlreadyExistsException.class)
public void testNewModuleCreationClashingGAV() throws URISyntaxException {
final Repository repository = mock(Repository.class);
final Path masterBranchRoot = mock(Path.class);
doReturn(Optional.of(new Branch("master", masterBranchRoot))).when(repository).getDefaultBranch();
final POM pom = new POM();
final String baseURL = "/";
final KieModule expected = new KieModule();
when(moduleRepositoryResolver.getRepositoriesResolvingArtifact(eq(pom.getGav()))).thenReturn(new HashSet<MavenRepositoryMetadata>() {
{
add(new MavenRepositoryMetadata("id", "url", MavenRepositorySource.SETTINGS));
}
});
when(saver.save(masterBranchRoot, pom, baseURL)).thenReturn(expected);
moduleService.newModule(masterBranchRoot, pom, baseURL);
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class FormsMigrationTool method systemMigrationWasExecuted.
private boolean systemMigrationWasExecuted() {
final IOService systemIoService = cdiWrapper.getSystemIoService();
final Repository systemRepository = cdiWrapper.getSystemRepository();
if (!systemIoService.exists(systemIoService.get(systemRepository.getUri()).resolve("spaces"))) {
system.err().println(String.format("The SYSTEM CONFIGURATION DIRECTORY STRUCTURE MIGRATION must be ran before this one."));
return false;
}
return true;
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class SourceServiceImplTest method testGetRepositories.
@Test
public void testGetRepositories() {
List<Repository> repositories = mockRepositories("RepoName.", REPOSITORIES_SIZE);
OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
when(organizationalUnit.getName()).thenReturn(OU_NAME);
// the organizational unit not exists.
when(organizationalUnitService.getOrganizationalUnit(OU_NAME)).thenReturn(null);
Collection<String> result = service.getRepositories(OU_NAME);
// nothing is returned.
assertTrue(result.isEmpty());
// there organizational unit exists, but no repository is authorized.
when(organizationalUnitService.getOrganizationalUnit(OU_NAME)).thenReturn(organizationalUnit);
when(organizationalUnit.getRepositories()).thenReturn(repositories);
result = service.getRepositories(OU_NAME);
// nothing is returned since there are no authorized repository.
assertTrue(result.isEmpty());
// finally we authorize some repositories. Take some arbitrary indexes.
List<Integer> authorizedIndexes = new ArrayList<>();
List<String> authorizedNames = new ArrayList<>();
authorizedIndexes.add(1);
authorizedIndexes.add(4);
authorizedIndexes.add(6);
authorizedIndexes.forEach(index -> {
when(authorizationManager.authorize(repositories.get(index), identity)).thenReturn(true);
authorizedNames.add(repositories.get(index).getAlias());
});
result = service.getRepositories(OU_NAME);
assertEquals(authorizedNames, result);
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class SourceServiceImplTest method mockRepositories.
private List<Repository> mockRepositories(String suffix, int count) {
List<Repository> result = new ArrayList<>();
for (int i = 0; i < count; i++) {
Repository repo = mock(Repository.class);
when(repo.getAlias()).thenReturn(suffix + i);
result.add(repo);
}
return result;
}
Aggregations