Search in sources :

Example 1 with BuildConfigurationRef

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

the class BuildConfigurationEndpointTest method testRemoveDependency.

@Test
@InSequence(40)
public void testRemoveDependency() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    // given
    BuildConfiguration parent = client.getSpecific(configuration3Id);
    Map<String, BuildConfigurationRef> oldDependencies = parent.getDependencies();
    assertThat(oldDependencies).isNotEmpty();
    BuildConfigurationRef toDelete = oldDependencies.values().iterator().next();
    // when
    client.removeDependency(parent.getId(), toDelete.getId());
    // then
    RemoteCollection<BuildConfiguration> all = client.getDependencies(parent.getId());
    oldDependencies.remove(toDelete.getId());
    assertThat(all).extracting(DTOEntity::getId).doesNotContain(toDelete.getId()).containsAll(oldDependencies.keySet().stream().collect(Collectors.toList()));
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) DTOEntity(org.jboss.pnc.dto.DTOEntity) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 2 with BuildConfigurationRef

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

the class BuildConfigurationEndpointTest method testAddDependency.

@Test
@InSequence(20)
public void testAddDependency() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    // given
    BuildConfiguration newDependency = createBuildConfigurationAndValidateResults(projectId, environmentId, repositoryConfigurationId, "dep-" + UUID.randomUUID(), PARAMETER_KEY);
    BuildConfiguration parent = client.getSpecific(configuration3Id);
    Map<String, BuildConfigurationRef> oldDependencies = parent.getDependencies();
    assertThat(oldDependencies).doesNotContainKey(newDependency.getId());
    // when
    client.addDependency(parent.getId(), newDependency);
    // then
    RemoteCollection<BuildConfiguration> all = client.getDependencies(parent.getId());
    assertThat(all).extracting(DTOEntity::getId).containsAll(oldDependencies.keySet().stream().collect(Collectors.toList())).contains(newDependency.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) DTOEntity(org.jboss.pnc.dto.DTOEntity) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 3 with BuildConfigurationRef

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

the class PncBuilderTest method getCountOfBuildConfigsForGroupBuild.

@Test
void getCountOfBuildConfigsForGroupBuild() throws Exception {
    Map<String, BuildConfigurationRef> buildConfigurations = new HashMap<>();
    BuildConfigurationRef bc1 = easyRandom.nextObject(BuildConfigurationRef.class);
    BuildConfigurationRef bc2 = easyRandom.nextObject(BuildConfigurationRef.class);
    BuildConfigurationRef bc3 = easyRandom.nextObject(BuildConfigurationRef.class);
    buildConfigurations.put(bc1.getName(), bc1);
    buildConfigurations.put(bc2.getName(), bc2);
    buildConfigurations.put(bc3.getName(), bc3);
    String groupConfigurationId = "5";
    String groupBuildId = "1";
    GroupConfiguration gc = GroupConfiguration.builder().id(groupConfigurationId).buildConfigs(buildConfigurations).build();
    GroupBuild gb = GroupBuild.builder().id(groupBuildId).groupConfig(gc).build();
    when(groupBuildClient.getSpecific(groupBuildId)).thenReturn(gb);
    when(groupConfigurationClient.getBuildConfigs(groupConfigurationId)).thenReturn(new RemoteCollection<BuildConfiguration>() {

        @Override
        public int size() {
            return buildConfigurations.size();
        }

        @Override
        public Collection<BuildConfiguration> getAll() {
            return null;
        }

        @Override
        public Iterator<BuildConfiguration> iterator() {
            return null;
        }
    });
    try (PncBuilder builder = new PncBuilder(groupBuildClient, groupConfigurationClient)) {
        assertEquals(buildConfigurations.size(), builder.getCountOfBuildConfigsForGroupBuild(groupBuildId));
    }
}
Also used : BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap) GroupBuild(org.jboss.pnc.dto.GroupBuild) Iterator(java.util.Iterator) Collection(java.util.Collection) RemoteCollection(org.jboss.pnc.client.RemoteCollection) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with BuildConfigurationRef

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

the class BuildConfigurationEndpointTest method shouldUpdateBuildConfigurationWithDependencies.

/**
 * Reproducer NCL-5686 - update of build configuration with dependencies, with cache enabled, is possible
 *
 * @throws Exception
 */
@Test
@InSequence(60)
public void shouldUpdateBuildConfigurationWithDependencies() throws ClientException {
    // given
    // Create dependency
    BuildConfiguration dependency = createBuildConfigurationAndValidateResults(projectId, environmentId, repositoryConfigurationId, "pnc-1.0.0.DR1", UUID.randomUUID().toString());
    // Create build configuration
    Map<String, BuildConfigurationRef> dependencies = new HashMap<>();
    dependencies.put(dependency.getId(), dependency);
    BuildConfiguration buildConfiguration = createBuildConfigurationWithDependencyAndValidateResults(projectId, environmentId, repositoryConfigurationId, "dependency-analysis-master", UUID.randomUUID().toString(), dependencies);
    final String updatedBuildScript = "mvn clean deploy -DskipTests=true";
    final Instant modificationTime = Instant.ofEpochMilli(155382545038L);
    BuildConfiguration updatedBuildConfiguration = BuildConfiguration.builder().id(buildConfiguration.getId()).name(buildConfiguration.getName()).buildScript(updatedBuildScript).creationTime(buildConfiguration.getCreationTime()).modificationTime(modificationTime).project(buildConfiguration.getProject()).environment(buildConfiguration.getEnvironment()).parameters(buildConfiguration.getParameters()).scmRepository(buildConfiguration.getScmRepository()).buildType(buildConfiguration.getBuildType()).build();
    // when
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    client.update(updatedBuildConfiguration.getId(), updatedBuildConfiguration);
    BuildConfiguration updatedBC = client.getSpecific(updatedBuildConfiguration.getId());
    // then
    assertThat(updatedBC.getId()).isEqualTo(buildConfiguration.getId());
    assertThat(updatedBC.getName()).isEqualTo("dependency-analysis-master");
    assertThat(updatedBC.getBuildScript()).isEqualTo(updatedBuildScript);
    assertThat(updatedBC.getScmRepository().getId()).isEqualTo(repositoryConfigurationId);
    assertThat(updatedBC.getProject().getId()).isEqualTo(projectId);
    assertThat(updatedBC.getEnvironment().getId()).isEqualTo(environmentId);
    assertThat(modificationTime).isNotEqualTo(updatedBC.getModificationTime());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) HashMap(java.util.HashMap) Instant(java.time.Instant) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with BuildConfigurationRef

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

the class GroupConfigurationEndpointTest method shouldUpdateAllBuildConfigurations.

@Test
public void shouldUpdateAllBuildConfigurations() throws Exception {
    // with
    GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    String gcId = "101";
    BuildConfiguration bc = bcClient.getAll().iterator().next();
    GroupConfiguration gc = client.getSpecific(gcId);
    String bcId = bc.getId();
    Map<String, BuildConfigurationRef> buildConfigurationMap = new HashMap<>();
    buildConfigurationMap.put(bcId, bc);
    GroupConfiguration updated = gc.toBuilder().buildConfigs(buildConfigurationMap).build();
    assertThat(gc.getBuildConfigs()).doesNotContainKey(bcId);
    // when
    client.update(gc.getId(), updated);
    // then
    assertThat(client.getSpecific(gcId).getBuildConfigs()).containsOnlyKeys(bcId);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) HashMap(java.util.HashMap) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)8 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)5 ContainerTest (org.jboss.pnc.test.category.ContainerTest)5 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)4 InSequence (org.jboss.arquillian.junit.InSequence)3 DTOEntity (org.jboss.pnc.dto.DTOEntity)2 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)2 Instant (java.time.Instant)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)1 RemoteCollection (org.jboss.pnc.client.RemoteCollection)1 GroupBuild (org.jboss.pnc.dto.GroupBuild)1 Project (org.jboss.pnc.dto.Project)1 Test (org.junit.jupiter.api.Test)1