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