Search in sources :

Example 6 with SCMRepository

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

Example 7 with SCMRepository

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

Example 8 with 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);
    }
}
Also used : RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration) SCMRepository(org.jboss.pnc.dto.SCMRepository) RepositoryCreationFailure(org.jboss.pnc.dto.notification.RepositoryCreationFailure)

Example 9 with SCMRepository

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

Example 10 with SCMRepository

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());
}
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