use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldMatchFullExternalRepositoryUrl.
@Test
public void shouldMatchFullExternalRepositoryUrl() throws ClientException {
SCMRepository repository = repositoryClient.getSpecific("100");
final String requestUrl1 = "ssh://github.com:22/project-ncl/pnc";
final String requestUrl2 = "ssh://github.com:22/project-ncl/pnc.git";
final String requestUrl3 = "github.com/project-ncl/pnc";
assertThat(repositoryClient.getAll(requestUrl1, null)).containsExactly(repository);
assertThat(repositoryClient.getAll(requestUrl2, null)).containsExactly(repository);
assertThat(repositoryClient.getAll(requestUrl3, null)).containsExactly(repository);
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryEndpointTest method shouldGetConflictWhenUpdatingExternalUrlToExistingOne.
@Test
public void shouldGetConflictWhenUpdatingExternalUrlToExistingOne() throws ClientException {
Iterator<SCMRepository> iterator = repositoryClient.getAll(null, null).iterator();
String existingExternalUrl = iterator.next().getExternalUrl();
SCMRepository randomScmRepository = iterator.next();
SCMRepository toUpdate = randomScmRepository.toBuilder().externalUrl(existingExternalUrl).build();
assertThatThrownBy(() -> repositoryClient.update(toUpdate.getId(), toUpdate)).hasCauseInstanceOf(ClientErrorException.class).has(new Condition<Throwable>((e -> ((ClientErrorException) e.getCause()).getResponse().getStatus() == 409), "HTTP 409 Conflict"));
}
use of org.jboss.pnc.dto.SCMRepository 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");
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class BuildStatusChangedTest method getBuild.
private Build getBuild() {
ProjectRef projectRef = ProjectRef.refBuilder().id("1").name("A").description("desc").projectUrl("url1").issueTrackerUrl("url2").build();
SCMRepository scmRepository = SCMRepository.builder().id("1").internalUrl("url1").externalUrl("url2").preBuildSyncEnabled(true).build();
Environment buildEnvironment = Environment.builder().id("1").name("jdk8").description("desc").systemImageRepositoryUrl("url").systemImageId("11").systemImageType(SystemImageType.DOCKER_IMAGE).deprecated(true).build();
User user = User.builder().id("1").username("user").build();
BuildConfigurationRevisionRef buildConfigurationRevisionRef = BuildConfigurationRevisionRef.refBuilder().id("1").rev(1).name("name").buildScript("true").scmRevision("awqs21").build();
return Build.builder().project(projectRef).scmRepository(scmRepository).environment(buildEnvironment).user(user).buildConfigRevision(buildConfigurationRevisionRef).status(BuildStatus.BUILDING).buildContentId("build-42").temporaryBuild(true).build();
}
use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.
the class SCMRepositoryProviderTest method testUpdateShouldFailWithConflict.
@Test
public void testUpdateShouldFailWithConflict() {
// with
String external = "http://external.sh/foo/bar";
when(repour.translateExternalUrl(external)).thenReturn(mock.getInternalUrl());
SCMRepository toUpdate1 = createNewSCMRepository(mockSecond.getExternalUrl(), mockInternalOnly.getInternalUrl(), mockInternalOnly.isPreBuildSyncEnabled(), mockInternalOnly.getId().toString());
SCMRepository toUpdate2 = createNewSCMRepository(external, mockInternalOnly.getInternalUrl(), mockInternalOnly.isPreBuildSyncEnabled(), mockInternalOnly.getId().toString());
// when-then
assertThatThrownBy(() -> provider.update(toUpdate1.getId(), toUpdate1)).isInstanceOf(ConflictedEntryException.class);
assertThatThrownBy(() -> provider.update(toUpdate2.getId(), toUpdate2)).isInstanceOf(ConflictedEntryException.class);
}
Aggregations