Search in sources :

Example 26 with SCMRepository

use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.

the class SCMRepositoryProviderTest method testStoreNewRepositoryWithInvalidInternalUrlShouldFail.

@Test
public void testStoreNewRepositoryWithInvalidInternalUrlShouldFail() {
    // when
    SCMRepository toCreate = createNewSCMRepository("https://" + UUID.randomUUID().toString() + ".ca", "noway" + UUID.randomUUID().toString(), true, null);
    // then
    assertThatThrownBy(() -> provider.store(toCreate)).isInstanceOf(InvalidEntityException.class);
}
Also used : SCMRepository(org.jboss.pnc.dto.SCMRepository) Test(org.junit.Test)

Example 27 with SCMRepository

use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.

the class SCMRepositoryProviderImpl method notifySCMRepositoryCreated.

private void notifySCMRepositoryCreated(RepositoryCreated event) {
    final SCMRepository repository = getSpecific(Integer.toString(event.getRepositoryId()));
    final String taskId = event.getTaskId() == null ? null : event.getTaskId().toString();
    if (taskId != null)
        notifier.sendMessage(new SCMRepositoryCreationSuccess(repository, taskId));
}
Also used : SCMRepository(org.jboss.pnc.dto.SCMRepository) SCMRepositoryCreationSuccess(org.jboss.pnc.dto.notification.SCMRepositoryCreationSuccess)

Example 28 with SCMRepository

use of org.jboss.pnc.dto.SCMRepository in project pnc by project-ncl.

the class SCMRepositoryProviderImpl method createSCMRepository.

@Override
public RepositoryCreationResponse createSCMRepository(String scmUrl, String revision, Boolean preBuildSyncEnabled, JobNotificationType jobType, Consumer<RepositoryCreated> consumer, Optional<BuildConfiguration> buildConfiguration) {
    log.trace("Received request to start RC creation with url autodetect: " + scmUrl + " (sync enabled? " + preBuildSyncEnabled + ")");
    if (StringUtils.isEmpty(scmUrl))
        throw new InvalidEntityException("You must specify the SCM URL.");
    if (scmUrl.contains(config.getInternalScmAuthority())) {
        // validation phase
        validateInternalRepository(scmUrl);
        validateRepositoryWithInternalURLDoesNotExist(scmUrl, null);
        SCMRepository scmRepository = createSCMRepositoryFromValues(null, scmUrl, false);
        consumer.accept(new RepositoryCreated(null, Integer.valueOf(scmRepository.getId())));
        return new RepositoryCreationResponse(scmRepository);
    } else {
        validateRepositoryWithExternalURLDoesNotExist(scmUrl, null);
        boolean sync = preBuildSyncEnabled == null || preBuildSyncEnabled;
        Integer taskId = startRCreationTask(scmUrl, revision, sync, jobType, consumer, buildConfiguration);
        return new RepositoryCreationResponse(taskId);
    }
}
Also used : SCMRepository(org.jboss.pnc.dto.SCMRepository) RepositoryCreationResponse(org.jboss.pnc.dto.response.RepositoryCreationResponse) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

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