use of org.jboss.pnc.dto.requests.CreateAndSyncSCMRequest in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldFailOnCreatingNewWithConflictingInternalUrl.
@Test
public void shouldFailOnCreatingNewWithConflictingInternalUrl() {
SCMRepository repository = SCMRepository.builder().internalUrl(// from DatabaseDataInitializer.class
"ssh://git@github.com:22/project-ncl/pnc.git").preBuildSyncEnabled(false).build();
CreateAndSyncSCMRequest request = CreateAndSyncSCMRequest.builder().scmUrl(repository.getInternalUrl()).preBuildSyncEnabled(repository.getPreBuildSyncEnabled()).build();
assertThatThrownBy(() -> repositoryClient.createNew(request)).hasCauseInstanceOf(ClientErrorException.class).has(new Condition<Throwable>((e -> ((ClientErrorException) e.getCause()).getResponse().getStatus() == 409), "Has Cause with conflicted status code 409"));
}
use of org.jboss.pnc.dto.requests.CreateAndSyncSCMRequest in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldFailToCreateNewWithInvalidUrl.
@Test
public void shouldFailToCreateNewWithInvalidUrl() {
SCMRepository repository = SCMRepository.builder().internalUrl(// from DatabaseDataInitializer
"I will totally fail!!").preBuildSyncEnabled(false).build();
CreateAndSyncSCMRequest request = CreateAndSyncSCMRequest.builder().scmUrl(repository.getInternalUrl()).preBuildSyncEnabled(repository.getPreBuildSyncEnabled()).build();
assertThatThrownBy(() -> repositoryClient.createNew(request)).hasCauseInstanceOf(BadRequestException.class);
}
use of org.jboss.pnc.dto.requests.CreateAndSyncSCMRequest in project bacon by project-ncl.
the class PncEntitiesImporter method createRepository.
private SCMRepository createRepository(BuildConfig buildConfig) {
String scmUrl = buildConfig.getScmUrl();
CreateAndSyncSCMRequest createRepoRequest = CreateAndSyncSCMRequest.builder().preBuildSyncEnabled(true).scmUrl(scmUrl).build();
try {
CompletableFuture<AdvancedSCMRepositoryClient.SCMCreationResult> response = repoClient.createNewAndWait(createRepoRequest);
log.info("Waiting for repository creation of '{}'", scmUrl);
SleepUtils.waitFor(response::isDone, 10, true);
AdvancedSCMRepositoryClient.SCMCreationResult result = response.join();
log.info("{}", result.toString());
if (result.isSuccess()) {
return result.getScmRepositoryCreationSuccess().getScmRepository();
} else {
throw new RuntimeException("Error on creation of repository: " + result.getRepositoryCreationFailure());
}
} catch (ClientException e) {
throw new RuntimeException("Failed to trigger repository creation for " + scmUrl, e);
}
}
use of org.jboss.pnc.dto.requests.CreateAndSyncSCMRequest in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldCreateNewWithInternalUrl.
@Test
public void shouldCreateNewWithInternalUrl() throws ClientException {
// With
SCMRepository repository = SCMRepository.builder().internalUrl("ssh://git@github.com:22/newUser/newRepo.git").preBuildSyncEnabled(false).build();
CreateAndSyncSCMRequest request = CreateAndSyncSCMRequest.builder().scmUrl(repository.getInternalUrl()).preBuildSyncEnabled(repository.getPreBuildSyncEnabled()).build();
// When
RepositoryCreationResponse response = repositoryClient.createNew(request);
// Then
assertThat(response).isNotNull();
assertThat(response.getRepository().getId()).isNotNull();
SCMRepository refreshed = repositoryClient.getSpecific(response.getRepository().getId());
assertThat(refreshed).isEqualToIgnoringGivenFields(repository, "id");
}
Aggregations