Search in sources :

Example 21 with SCMRepository

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);
}
Also used : SCMRepository(org.jboss.pnc.dto.SCMRepository) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 22 with SCMRepository

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"));
}
Also used : ClientErrorException(javax.ws.rs.ClientErrorException) SCMRepository(org.jboss.pnc.dto.SCMRepository) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 23 with SCMRepository

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");
}
Also used : CreateAndSyncSCMRequest(org.jboss.pnc.dto.requests.CreateAndSyncSCMRequest) SCMRepository(org.jboss.pnc.dto.SCMRepository) RepositoryCreationResponse(org.jboss.pnc.dto.response.RepositoryCreationResponse) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 24 with SCMRepository

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();
}
Also used : User(org.jboss.pnc.dto.User) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) Environment(org.jboss.pnc.dto.Environment) ProjectRef(org.jboss.pnc.dto.ProjectRef) SCMRepository(org.jboss.pnc.dto.SCMRepository)

Example 25 with SCMRepository

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);
}
Also used : SCMRepository(org.jboss.pnc.dto.SCMRepository) Test(org.junit.Test)

Aggregations

SCMRepository (org.jboss.pnc.dto.SCMRepository)28 Test (org.junit.Test)17 ContainerTest (org.jboss.pnc.test.category.ContainerTest)9 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)8 Environment (org.jboss.pnc.dto.Environment)5 ProjectRef (org.jboss.pnc.dto.ProjectRef)4 CreateAndSyncSCMRequest (org.jboss.pnc.dto.requests.CreateAndSyncSCMRequest)4 ClientErrorException (javax.ws.rs.ClientErrorException)3 SCMRepositoryClient (org.jboss.pnc.client.SCMRepositoryClient)3 RepositoryCreationResponse (org.jboss.pnc.dto.response.RepositoryCreationResponse)3 InvalidEntityException (org.jboss.pnc.facade.validation.InvalidEntityException)3 RepositoryConfiguration (org.jboss.pnc.model.RepositoryConfiguration)3 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)2 EnvironmentClient (org.jboss.pnc.client.EnvironmentClient)2 Project (org.jboss.pnc.dto.Project)2 BuildConfigurationCreation (org.jboss.pnc.dto.notification.BuildConfigurationCreation)2 ConflictedEntryException (org.jboss.pnc.facade.validation.ConflictedEntryException)2 DTOValidationException (org.jboss.pnc.facade.validation.DTOValidationException)2 EmptyEntityException (org.jboss.pnc.facade.validation.EmptyEntityException)2 RepositoryViolationException (org.jboss.pnc.facade.validation.RepositoryViolationException)2