use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldUpdate.
@Test
public void shouldUpdate() throws ClientException {
// with
SCMRepository scmRepository = repositoryClient.getAll(null, null).iterator().next();
SCMRepository toUpdate = scmRepository.toBuilder().externalUrl("http://newUrl.com/newproject/project.git").build();
// when
repositoryClient.update(scmRepository.getId(), toUpdate);
// then
SCMRepository refreshed = repositoryClient.getSpecific(toUpdate.getId());
assertThat(refreshed).isEqualToComparingFieldByField(toUpdate);
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class BuildBCRevisionFetcher method mapFromAuditedBuildConfig.
@BeforeMapping
public void mapFromAuditedBuildConfig(BuildRecord build, @MappingTarget Build.Builder dtoBuilder) {
Integer id = build.getBuildConfigurationId();
Integer revision = build.getBuildConfigurationRev();
// If somebody before us already set the BCA we don't need to query it from DB again
BuildConfigurationAudited bca = build.getBuildConfigurationAudited();
if (bca == null) {
bca = bcAuditedRepository.queryById(new IdRev(id, revision));
}
BuildConfigurationRevisionRef bcRevision = bcRevisionMapper.toRef(bca);
ProjectRef project = projectMapper.toRef(bca.getProject());
Environment environment = environmentMapper.toRef(bca.getBuildEnvironment());
SCMRepository scmRepository = scmRepositoryMapper.toRef(bca.getRepositoryConfiguration());
dtoBuilder.buildConfigRevision(bcRevision);
dtoBuilder.project(project);
dtoBuilder.environment(environment);
dtoBuilder.scmRepository(scmRepository);
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryProviderImpl method onRepoCloneSuccess.
private void onRepoCloneSuccess(String internalScmUrl, Integer taskId, Consumer<RepositoryCreated> consumer, JobNotificationType jobType, String externalURL, boolean preBuildSyncEnabled) {
RepositoryConfiguration existing = repository.queryByPredicates(withExactInternalScmRepoUrl(internalScmUrl));
if (existing != null) {
RepositoryCreationFailure error = new RepositoryCreationFailure(jobType, RC_REPO_CREATION_CONFLICT, existing, taskId.toString());
notifier.sendMessage(error);
} else {
SCMRepository scmRepo = createSCMRepositoryFromValues(externalURL, internalScmUrl, preBuildSyncEnabled);
RepositoryCreated notification = new RepositoryCreated(taskId, Integer.parseInt(scmRepo.getId()));
consumer.accept(notification);
}
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryProviderTest method testUpdate.
@Test
public void testUpdate() {
// when
boolean newPreSync = !mock.isPreBuildSyncEnabled();
SCMRepository toUpdate = createNewSCMRepository(mock.getExternalUrl(), mock.getInternalUrl(), newPreSync, mock.getId().toString());
provider.update(toUpdate.getId(), toUpdate);
SCMRepository updated = provider.getSpecific(toUpdate.getId());
// then
assertThat(updated.getId()).isEqualTo(mock.getId().toString());
assertThat(updated.getExternalUrl()).isEqualTo(mock.getExternalUrl());
assertThat(updated.getInternalUrl()).isEqualTo(mock.getInternalUrl());
assertThat(updated.getPreBuildSyncEnabled()).isEqualTo(newPreSync);
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryProviderTest method testGetSpecific.
@Test
public void testGetSpecific() {
// when
SCMRepository repo = provider.getSpecific(mock.getId().toString());
// then
assertThat(repo).isNotNull();
assertThat(repo.getId()).isEqualTo(mock.getId().toString());
assertThat(repo.getExternalUrl()).isEqualTo(mock.getExternalUrl());
assertThat(repo.getInternalUrl()).isEqualTo(mock.getInternalUrl());
assertThat(repo.getPreBuildSyncEnabled()).isEqualTo(mock.isPreBuildSyncEnabled());
}
Aggregations