Search in sources :

Example 31 with BuildConfiguration

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

the class GroupConfigurationEndpointTest method testRemoveBuildConfigFromGroupConfig.

@Test
public void testRemoveBuildConfigFromGroupConfig() throws ClientException {
    // with
    GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
    String gcId = "100";
    BuildConfiguration configuration = client.getBuildConfigs(gcId).iterator().next();
    // when
    client.removeBuildConfig(gcId, configuration.getId());
    // then
    GroupConfiguration refreshed = client.getSpecific(gcId);
    assertThat(refreshed).isNotNull();
    assertThat(refreshed.getBuildConfigs()).doesNotContainKey(configuration.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 32 with BuildConfiguration

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

the class ProductVersionEndpointTest method testGetBuildConfigurations.

@Test
public void testGetBuildConfigurations() throws ClientException {
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<BuildConfiguration> all = client.getBuildConfigs(productVersionsId);
    assertThat(all).hasSize(2).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 33 with BuildConfiguration

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

the class ProductVersionEndpointTest method shouldDeleteBuildConfigWithPatch.

@Test
public void shouldDeleteBuildConfigWithPatch() throws Exception {
    // given
    ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    ProductVersion productVersion = client.getSpecific(productVersionsId2);
    assertThat(productVersion.getBuildConfigs()).isNotEmpty();
    BuildConfiguration toRemove = bcClient.getSpecific(productVersion.getBuildConfigs().keySet().iterator().next());
    ProductVersionPatchBuilder builder = new ProductVersionPatchBuilder();
    builder.removeBuildConfigs(Collections.singletonList(toRemove.getId()));
    // when
    client.patch(productVersion.getId(), builder);
    // then
    ProductVersion refresh = client.getSpecific(productVersionsId2);
    assertThat(refresh.getBuildConfigs().keySet()).doesNotContain(toRemove.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ProductVersion(org.jboss.pnc.dto.ProductVersion) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ProductVersionPatchBuilder(org.jboss.pnc.client.patch.ProductVersionPatchBuilder) ProductVersionClient(org.jboss.pnc.client.ProductVersionClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 34 with BuildConfiguration

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

the class RSQLPredicateProducerTest method testComparatorUnknownQuery.

@Test
public void testComparatorUnknownQuery() {
    Comparator<BuildConfiguration> comparator = producer.getComparator("=desc=fieldThatDoesNotExists");
    BuildConfiguration foo = BuildConfiguration.builder().id("3").name("FooBC").build();
    BuildConfiguration bar = BuildConfiguration.builder().id("5").name("BarBC").build();
    BuildConfiguration baz = BuildConfiguration.builder().id("7").name("BazBC").build();
    try {
        List<BuildConfiguration> sorted = Arrays.asList(foo, bar, baz).stream().sorted(comparator).collect(Collectors.toList());
        fail("Exception expected");
    } catch (RuntimeException ex) {
    // ok
    }
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Example 35 with BuildConfiguration

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

the class BuildConfigurationProviderImpl method createBuildConfigurationWithRepository.

public void createBuildConfigurationWithRepository(String taskId, int scmRepositoryId, BuildConfiguration configuration) {
    RepositoryConfiguration repositoryConfiguration = repositoryConfigurationRepository.queryById(scmRepositoryId);
    final boolean sendMessage = taskId != null;
    if (repositoryConfiguration == null) {
        String errorMessage = "Repository Configuration was not found in database.";
        logger.error(errorMessage);
        if (sendMessage) {
            sendErrorMessage(SCMRepository.builder().id(Integer.toString(scmRepositoryId)).build(), null, errorMessage, taskId);
            return;
        }
        throw new RepositoryViolationException("Repository Configuration was not found in database.");
    }
    org.jboss.pnc.model.BuildConfiguration buildConfiguration = mapper.toEntity(configuration);
    buildConfiguration.setRepositoryConfiguration(repositoryConfiguration);
    org.jboss.pnc.model.BuildConfiguration buildConfigurationSaved = repository.save(buildConfiguration);
    Set<Integer> bcSetIds;
    if (configuration.getGroupConfigs() == null) {
        bcSetIds = Collections.emptySet();
    } else {
        bcSetIds = configuration.getGroupConfigs().keySet().stream().map(Integer::valueOf).collect(Collectors.toSet());
    }
    SCMRepository scmRepository = scmRepositoryMapper.toDTO(repositoryConfiguration);
    BuildConfiguration buildConfig = mapper.toDTO(buildConfigurationSaved);
    try {
        addBuildConfigurationToSet(buildConfigurationSaved, bcSetIds);
    } catch (Exception e) {
        logger.error(e.getMessage());
        if (sendMessage) {
            sendErrorMessage(scmRepository, buildConfig, e.getMessage(), taskId);
            return;
        }
        throw new RepositoryViolationException("Failed to add BuildConfig to BuildConfigSets.");
    }
    logger.info("Created Build Configuration with Repository: {}.", buildConfig);
    if (sendMessage) {
        BuildConfigurationCreation successMessage = BuildConfigurationCreation.success(scmRepository, buildConfig, taskId);
        notifier.sendMessage(successMessage);
    }
}
Also used : BuildConfigurationCreation(org.jboss.pnc.dto.notification.BuildConfigurationCreation) EmptyEntityException(org.jboss.pnc.facade.validation.EmptyEntityException) RepositoryViolationException(org.jboss.pnc.facade.validation.RepositoryViolationException) ConflictedEntryException(org.jboss.pnc.facade.validation.ConflictedEntryException) DTOValidationException(org.jboss.pnc.facade.validation.DTOValidationException) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) RepositoryViolationException(org.jboss.pnc.facade.validation.RepositoryViolationException) RepositoryConfiguration(org.jboss.pnc.model.RepositoryConfiguration) SCMRepository(org.jboss.pnc.dto.SCMRepository)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3