use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.
the class BuildParametersValidatorTest method testBuildParametersValidation.
@Test
@Parameterized.Parameters
public void testBuildParametersValidation() {
BuildParameters buildParameters = new BuildParameters();
buildParameters.setTemporaryBuild(temporary);
buildParameters.setAlignmentPreference(alignmentPreference);
Set<ConstraintViolation<BuildParameters>> violations = validator.validate(buildParameters);
Assert.assertEquals(isValid, violations.isEmpty());
}
use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.
the class WebSocketClientTest method testBuildListener.
@Test
public void testBuildListener() throws Exception {
// with
WebSocketClient wsClient = new VertxWebSocketClient();
wsClient.connect(PNC_SOCKET_URL).get();
BuildConfigurationClient buildConfigurationClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
BuildConfiguration bc = buildConfigurationClient.getAll().iterator().next();
AtomicInteger notificationCounter = new AtomicInteger(0);
// when
ListenerUnsubscriber unsubscriber = wsClient.onBuildChangedNotification((notification -> {
notificationCounter.incrementAndGet();
assertThat(notification).isNotNull();
assertThat(notification.getBuild()).isNotNull();
}), withBuildConfiguration(bc.getId()));
buildConfigurationClient.trigger(bc.getId(), new BuildParameters());
// then
Thread.sleep(1000);
unsubscriber.run();
wsClient.disconnect().get();
assertThat(notificationCounter).hasValueGreaterThanOrEqualTo(2);
}
use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.
the class BuildTest method getBuildParameters.
private BuildParameters getBuildParameters(boolean temporary, boolean force) {
BuildParameters buildParameters = new BuildParameters();
buildParameters.setTemporaryBuild(temporary);
buildParameters.setBuildDependencies(true);
if (force)
buildParameters.setRebuildMode(RebuildMode.FORCE);
return buildParameters;
}
use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.
the class RemoteBuildTest method runMultipleBuilds.
@Test
public void runMultipleBuilds() throws Exception {
String bcID = prepareBuildConfiguration("test-build-execution");
BuildParameters buildOptions = new BuildParameters();
buildOptions.setBuildDependencies(false);
buildOptions.setRebuildMode(RebuildMode.FORCE);
for (int i = 0; i < 20; i++) {
CompletableFuture<Build> executeBuild = buildConfigurationRestClient.executeBuild(bcID, buildOptions);
Build build = executeBuild.get(1, TimeUnit.MINUTES);
assertThat(build.getStatus().completedSuccessfully()).isTrue();
}
}
use of org.jboss.pnc.rest.api.parameters.BuildParameters in project pnc by project-ncl.
the class WebSocketClientTest method testRestBuildFallback.
@Test
public void testRestBuildFallback() throws Exception {
// with
WebSocketSessionHandler handler = new WebSocketSessionHandler();
Undertow wsServer = withHandler(handler);
wsServer.start();
WebSocketClient wsClient = new VertxWebSocketClient();
wsClient.connect("ws://localhost:8082" + NOTIFICATION_PATH).join();
AdvancedBuildConfigurationClient buildConfigurationClient = new AdvancedBuildConfigurationClient(RestClientConfiguration.asUser());
// test the actual fallbackSupplier (it's private -> reflection unfortunately)
Method supplier = buildConfigurationClient.getClass().getDeclaredMethod("fallbackSupplier", String.class);
supplier.setAccessible(true);
// when
BuildConfiguration bc = buildConfigurationClient.getAll().iterator().next();
CompletableFuture<BuildChangedNotification> future = wsClient.catchBuildChangedNotification(() -> invokeMethod(supplier, Build.class, buildConfigurationClient, bc.getId()), withBuildConfiguration(bc.getId()), withBuildCompleted());
buildConfigurationClient.trigger(bc.getId(), new BuildParameters());
// make client reconnect and use REST fallback
handler.closeSession();
// then
assertThat(future).succeedsWithin(1000, TimeUnit.MILLISECONDS);
wsClient.close();
wsServer.stop();
}
Aggregations