use of org.guvnor.common.services.project.model.MavenRepositoryMetadata in project kie-wb-common by kiegroup.
the class ModuleRepositoriesSynchronizerTest method testAddModuleRepository.
@Test
public void testAddModuleRepository() {
final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
final ModuleRepositories moduleRepositories = new ModuleRepositories();
when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
when(repositoryResolver.getRemoteRepositoriesMetaData(module)).thenReturn(new HashSet<MavenRepositoryMetadata>() {
{
add(new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL));
}
});
synchronizer.onResourceUpdated(event);
final ArgumentCaptor<ModuleRepositories> moduleRepositoriesArgumentCaptor = ArgumentCaptor.forClass(ModuleRepositories.class);
verify(moduleRepositoriesService, times(1)).save(eq(moduleRepositoriesPath), moduleRepositoriesArgumentCaptor.capture(), any(String.class));
final ModuleRepositories saved = moduleRepositoriesArgumentCaptor.getValue();
assertNotNull(saved);
assertEquals(1, saved.getRepositories().size());
final ModuleRepositories.ModuleRepository repository = saved.getRepositories().iterator().next();
assertTrue(repository.isIncluded());
assertEquals("local-id", repository.getMetadata().getId());
assertEquals("local-url", repository.getMetadata().getUrl());
assertEquals(MavenRepositorySource.LOCAL, repository.getMetadata().getSource());
}
use of org.guvnor.common.services.project.model.MavenRepositoryMetadata in project kie-wb-common by kiegroup.
the class ModuleRepositoriesSynchronizerTest method testRemoveModuleRepository.
@Test
public void testRemoveModuleRepository() {
final ResourceUpdatedEvent event = new ResourceUpdatedEvent(pomPath, "", sessionInfo);
final Set<ModuleRepositories.ModuleRepository> repositories = new HashSet<ModuleRepositories.ModuleRepository>() {
{
add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL)));
}
};
final ModuleRepositories moduleRepositories = new ModuleRepositories(repositories);
when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
synchronizer.onResourceUpdated(event);
final ArgumentCaptor<ModuleRepositories> moduleRepositoriesArgumentCaptor = ArgumentCaptor.forClass(ModuleRepositories.class);
verify(moduleRepositoriesService, times(1)).save(eq(moduleRepositoriesPath), moduleRepositoriesArgumentCaptor.capture(), any(String.class));
final ModuleRepositories saved = moduleRepositoriesArgumentCaptor.getValue();
assertNotNull(saved);
assertEquals(0, saved.getRepositories().size());
}
use of org.guvnor.common.services.project.model.MavenRepositoryMetadata in project kie-wb-common by kiegroup.
the class ModuleServiceImplNewModuleTest method testNewModuleCreationClashingGAVForced.
@Test()
public void testNewModuleCreationClashingGAVForced() 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);
try {
moduleService.newModule(masterBranchRoot, pom, baseURL, DeploymentMode.FORCED);
} catch (GAVAlreadyExistsException e) {
fail("Unexpected exception thrown: " + e.getMessage());
}
}
use of org.guvnor.common.services.project.model.MavenRepositoryMetadata 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);
}
Aggregations