Search in sources :

Example 6 with BuildConfigurationRef

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

the class ProjectEndpointTest method shouldNotAllowChangingTheListOfConfigurationFromProject.

@Test
public void shouldNotAllowChangingTheListOfConfigurationFromProject() throws ClientException {
    // when
    Project existingProject = client.getSpecific("100");
    Map<String, BuildConfigurationRef> buildConfigRefs = existingProject.getBuildConfigs();
    Project original = Project.builder().name("New name new me: " + UUID.randomUUID().toString()).build();
    Project projectReturned = client.createNew(original);
    Project projectUpdateRequest = Project.builder().id(projectReturned.getId()).name(projectReturned.getName()).buildConfigs(buildConfigRefs).build();
    client.update(projectReturned.getId(), projectUpdateRequest);
    Project projectUpdated = client.getSpecific(projectReturned.getId());
    // then
    assertThat(projectUpdated.getBuildConfigs()).hasSize(0);
}
Also used : BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) Project(org.jboss.pnc.dto.Project) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 7 with BuildConfigurationRef

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

the class BuildConfigurationPatchTest method shouldReplaceCollection.

@Test
public void shouldReplaceCollection() throws PatchBuilderException, IOException, JsonPatchException {
    BuildConfigurationRef dependency1 = BuildConfigurationRef.refBuilder().id("1").build();
    BuildConfigurationRef dependency2 = BuildConfigurationRef.refBuilder().id("2").build();
    BuildConfigurationRef dependency2a = BuildConfigurationRef.refBuilder().id("2").build();
    BuildConfigurationRef dependency3 = BuildConfigurationRef.refBuilder().id("3").build();
    BuildConfigurationRef dependency4 = BuildConfigurationRef.refBuilder().id("4").build();
    Map<String, BuildConfigurationRef> dependencies = new HashMap<>();
    dependencies.put(dependency1.getId(), dependency1);
    dependencies.put(dependency2.getId(), dependency2);
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().id("1").dependencies(dependencies).build();
    Map<String, BuildConfigurationRef> newDependencies = new HashMap<>();
    newDependencies.put(dependency2a.getId(), dependency2a);
    newDependencies.put(dependency3.getId(), dependency3);
    newDependencies.put(dependency4.getId(), dependency4);
    String patchString = new BuildConfigurationPatchBuilder().replaceDependencies(newDependencies).getJsonPatch();
    BuildConfiguration updatedBuildConfiguration = applyPatch(buildConfiguration, patchString);
    Assertions.assertThat(updatedBuildConfiguration.getDependencies()).containsOnly(newDependencies.entrySet().toArray(new Map.Entry[3]));
}
Also used : BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 8 with BuildConfigurationRef

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

the class BuildConfigurationPatchTest method shouldAddToCollection.

@Test
public void shouldAddToCollection() throws PatchBuilderException, IOException, JsonPatchException {
    Map<String, BuildConfigurationRef> dependencies = new HashMap<>();
    BuildConfigurationRef dependency1 = BuildConfigurationRef.refBuilder().id("1").build();
    dependencies.put(dependency1.getId(), dependency1);
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().id("1").dependencies(dependencies).build();
    Map<String, BuildConfigurationRef> addDependencies = new HashMap<>();
    BuildConfigurationRef dependency2 = BuildConfigurationRef.refBuilder().id("2").build();
    addDependencies.put(dependency2.getId(), dependency2);
    String patchString = new BuildConfigurationPatchBuilder().addDependencies(addDependencies).getJsonPatch();
    BuildConfiguration updatedBuildConfiguration = applyPatch(buildConfiguration, patchString);
    dependencies.putAll(addDependencies);
    Assertions.assertThat(updatedBuildConfiguration.getDependencies()).containsKeys(dependency1.getId(), dependency2.getId());
}
Also used : BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap) 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