use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method shouldDeleteBuildConfigWithPatch.
@Test
public void shouldDeleteBuildConfigWithPatch() throws Exception {
// given
GroupConfigurationClient groupConfigurationClient = new GroupConfigurationClient(RestClientConfiguration.asUser());
BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
GroupConfiguration gc = groupConfigurationClient.getAll().iterator().next();
assertThat(gc.getBuildConfigs()).isNotEmpty();
BuildConfiguration toRemove = bcClient.getSpecific(gc.getBuildConfigs().keySet().iterator().next());
GroupConfigurationPatchBuilder builder = new GroupConfigurationPatchBuilder();
builder.removeBuildConfigs(Collections.singletonList(toRemove.getId()));
// when
groupConfigurationClient.patch(gc.getId(), builder);
// then
GroupConfiguration refresh = groupConfigurationClient.getSpecific(gc.getId());
assertThat(refresh.getBuildConfigs().keySet()).doesNotContain(toRemove.getId());
}
use of org.jboss.pnc.dto.GroupConfiguration 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());
}
use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class ProductVersionEndpointTest method shouldUpdateGroupConfigsUsingPatch.
@Test
public void shouldUpdateGroupConfigsUsingPatch() throws PatchBuilderException, RemoteResourceException {
// given
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asUser());
GroupConfiguration gc = GroupConfiguration.builder().name("GC patch test").build();
GroupConfigurationClient gcc = new GroupConfigurationClient(RestClientConfiguration.asUser());
GroupConfiguration gcToAdd = gcc.createNew(gc);
ProductVersion productVersion = client.getSpecific(productVersionsId2);
Map<String, GroupConfigurationRef> groupConfigs = productVersion.getGroupConfigs();
// when
ProductVersionPatchBuilder patchBuilder = new ProductVersionPatchBuilder();
ProductVersionPatchBuilder patch = patchBuilder.addGroupConfigs(Collections.singletonMap(gcToAdd.getId(), gcToAdd));
client.patch(productVersionsId2, patch);
// then
groupConfigs.put(gcToAdd.getId(), gcToAdd);
ProductVersion productVersionUpdated = client.getSpecific(productVersionsId2);
assertThat(productVersionUpdated.getGroupConfigs()).containsKeys(groupConfigs.keySet().toArray(new String[groupConfigs.keySet().size()]));
}
use of org.jboss.pnc.dto.GroupConfiguration in project pnc by project-ncl.
the class ProductVersionEndpointTest method testGetGroupConfigurations.
@Test
public void testGetGroupConfigurations() throws ClientException {
ProductVersionClient client = new ProductVersionClient(RestClientConfiguration.asAnonymous());
RemoteCollection<GroupConfiguration> all = client.getGroupConfigs(productVersionsId);
assertThat(all).hasSize(2).allMatch(v -> v.getProductVersion().getId().equals(productVersionsId));
}
use of org.jboss.pnc.dto.GroupConfiguration 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));
}
}
Aggregations