use of org.jboss.pnc.client.GroupConfigurationClient in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method testConcurrentGet.
/**
* reproducer for NCL-3552
*/
@Test
public void testConcurrentGet() throws RemoteResourceException {
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
Map<Integer, RemoteCollection<BuildConfiguration>> responseMap = new HashMap<>();
String gcId = "100";
ExecutorService executorService = MDCExecutors.newFixedThreadPool(2);
executorService.execute(() -> {
logger.info("Making 1st request ...");
RemoteCollection<BuildConfiguration> configurations = null;
try {
configurations = client.getBuildConfigs(gcId);
} catch (RemoteResourceException e) {
// detected with null in responseMap
}
logger.info("1st done.");
responseMap.put(1, configurations);
});
executorService.execute(() -> {
logger.info("Making 2nd request ...");
RemoteCollection<BuildConfiguration> configurations = null;
try {
configurations = client.getBuildConfigs(gcId);
} catch (RemoteResourceException e) {
// detected with null in responseMap
}
logger.info("2nd done.");
responseMap.put(2, configurations);
});
try {
executorService.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
executorService.shutdownNow();
throw new AssertionError("Requests were not completed in given timeout.", e);
}
assertThat(responseMap).containsKeys(1, 2).doesNotContainValue(null);
}
use of org.jboss.pnc.client.GroupConfigurationClient in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method testCreateNewGroupConfig.
@Test
public void testCreateNewGroupConfig() throws ClientException {
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
final String name = "Testing 101";
GroupConfiguration gc = GroupConfiguration.builder().productVersion(ProductVersionRef.refBuilder().id("101").build()).name(name).build();
GroupConfiguration created = client.createNew(gc);
assertEquals(name, created.getName());
GroupConfiguration specific = client.getSpecific(created.getId());
assertEquals(created, specific);
}
use of org.jboss.pnc.client.GroupConfigurationClient in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method testUpdateGroupConfig.
@Test
public void testUpdateGroupConfig() throws ClientException {
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
final String name = "Testing 100 Updated";
GroupConfiguration specific = client.getSpecific("100");
GroupConfiguration updating = specific.toBuilder().name(name).build();
client.update("100", updating);
GroupConfiguration updated = client.getSpecific("100");
assertEquals(name, updated.getName());
}
use of org.jboss.pnc.client.GroupConfigurationClient 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.client.GroupConfigurationClient in project pnc by project-ncl.
the class GroupConfigurationEndpointTest method testGetSpecificGroupConfig.
@Test
public void testGetSpecificGroupConfig() throws ClientException {
String gcid = "100";
GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
assertThat(client.getSpecific(gcid)).isNotNull();
}
Aggregations