use of org.guvnor.common.services.project.model.ModuleRepositories in project kie-wb-common by kiegroup.
the class ValidationPresenterTest method testSetup.
@Test
public void testSetup() {
final ProjectScreenModel model = mock(ProjectScreenModel.class);
doReturn(new ModuleRepositories()).when(model).getRepositories();
validationPresenter.setup(model).catch_(i -> {
Assert.fail("Promise should've been resolved!");
return promises.resolve();
});
verify(view).init(eq(validationPresenter));
verify(validationItemPresenters).setup(any(), any(), any());
}
use of org.guvnor.common.services.project.model.ModuleRepositories in project kie-wb-common by kiegroup.
the class ValidationPresenterTest method testCurrentHashCode.
@Test
public void testCurrentHashCode() {
final ProjectScreenModel model = mock(ProjectScreenModel.class);
final ModuleRepositories repositories = new ModuleRepositories();
doReturn(repositories).when(model).getRepositories();
validationPresenter.setup(model);
int currentHashCode = validationPresenter.currentHashCode();
Assert.assertEquals(repositories.getRepositories().hashCode(), currentHashCode);
repositories.getRepositories().add(mock(ModuleRepositories.ModuleRepository.class));
int updatedHashCode = validationPresenter.currentHashCode();
Assert.assertEquals(repositories.getRepositories().hashCode(), updatedHashCode);
}
use of org.guvnor.common.services.project.model.ModuleRepositories in project kie-wb-common by kiegroup.
the class PomEditorServiceImplTest method testSaveNonClashingGAVChangeToGAV.
@Test
public void testSaveNonClashingGAVChangeToGAV() {
final Set<ModuleRepositories.ModuleRepository> moduleRepositoriesMetadata = new HashSet<ModuleRepositories.ModuleRepository>();
final ModuleRepositories moduleRepositories = new ModuleRepositories(moduleRepositoriesMetadata);
when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
final ArgumentCaptor<MavenRepositoryMetadata> resolvedRepositoriesCaptor = ArgumentCaptor.forClass(MavenRepositoryMetadata.class);
when(repositoryResolver.getRepositoriesResolvingArtifact(eq(pomXml), resolvedRepositoriesCaptor.capture())).thenReturn(Collections.EMPTY_SET);
when(pom.getGav()).thenReturn(new GAV("groupId", "artifactId", "0.0.2"));
service.save(pomPath, pomXml, metaData, comment, DeploymentMode.VALIDATED);
verify(moduleService, times(1)).resolveModule(pomPath);
verify(moduleRepositoriesService, times(1)).load(moduleRepositoriesPath);
verify(repositoryResolver, times(1)).getRepositoriesResolvingArtifact(eq(pomXml));
final List<MavenRepositoryMetadata> resolvedRepositories = resolvedRepositoriesCaptor.getAllValues();
assertNotNull(resolvedRepositories);
assertEquals(0, resolvedRepositories.size());
verify(ioService, times(1)).startBatch(any(FileSystem.class));
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), eq(pomXml), eq(attributes), any(CommentedOption.class));
verify(ioService, times(1)).endBatch();
}
use of org.guvnor.common.services.project.model.ModuleRepositories in project kie-wb-common by kiegroup.
the class PomEditorServiceImplTest method testSaveClashingGAVForced.
@Test
public void testSaveClashingGAVForced() {
final Set<ModuleRepositories.ModuleRepository> moduleRepositoriesMetadata = new HashSet<ModuleRepositories.ModuleRepository>() {
{
add(new ModuleRepositories.ModuleRepository(true, new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL)));
}
};
final ModuleRepositories moduleRepositories = new ModuleRepositories(moduleRepositoriesMetadata);
when(moduleRepositoriesService.load(moduleRepositoriesPath)).thenReturn(moduleRepositories);
final Set<MavenRepositoryMetadata> clashingRepositories = new HashSet<MavenRepositoryMetadata>() {
{
add(new MavenRepositoryMetadata("local-id", "local-url", MavenRepositorySource.LOCAL));
}
};
when(repositoryResolver.getRepositoriesResolvingArtifact(eq(pomXml), any(MavenRepositoryMetadata.class))).thenReturn(clashingRepositories);
when(pom.getGav()).thenReturn(new GAV("groupId", "artifactId", "0.0.1"));
try {
service.save(pomPath, pomXml, metaData, comment, DeploymentMode.FORCED);
} catch (GAVAlreadyExistsException e) {
fail(e.getMessage());
}
verify(moduleService, never()).resolveModule(pomPath);
verify(moduleRepositoriesService, never()).load(pomPath);
verify(repositoryResolver, never()).getRepositoriesResolvingArtifact(eq(pomXml), any(MavenRepositoryMetadata.class));
verify(ioService, times(1)).startBatch(any(FileSystem.class));
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), eq(pomXml), eq(attributes), any(CommentedOption.class));
verify(ioService, times(1)).endBatch();
}
use of org.guvnor.common.services.project.model.ModuleRepositories in project kie-wb-common by kiegroup.
the class ProjectScreenModelLoaderTest method testRepositories.
@Test
public void testRepositories() throws Exception {
final ModuleRepositories moduleRepositories = new ModuleRepositories();
when(moduleRepositoriesService.load(repositoriesPath)).thenReturn(moduleRepositories);
ProjectScreenModel model = loader.load(pathToPom);
assertEquals(repositoriesPath, model.getPathToRepositories());
assertEquals(moduleRepositories, model.getRepositories());
}
Aggregations