use of org.jboss.pnc.dto.notification.BuildChangedNotification in project pnc by project-ncl.
the class DefaultNotifier method collectBuildStatusChangedEvent.
public void collectBuildStatusChangedEvent(@Observes BuildStatusChangedEvent buildStatusChangedEvent) {
logger.trace("Observed new status changed event {}.", buildStatusChangedEvent);
sendMessage(new BuildChangedNotification(buildStatusChangedEvent.getOldStatus(), buildStatusChangedEvent.getBuild()));
logger.trace("Status changed event processed {}.", buildStatusChangedEvent);
}
use of org.jboss.pnc.dto.notification.BuildChangedNotification 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();
}
use of org.jboss.pnc.dto.notification.BuildChangedNotification in project pnc by project-ncl.
the class WebSocketClientTest method testNotificationCatcher.
@Test
public void testNotificationCatcher() 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();
// when
CompletableFuture<BuildChangedNotification> future = wsClient.catchBuildChangedNotification(withBuildConfiguration(bc.getId()), withBuildCompleted());
buildConfigurationClient.trigger(bc.getId(), new BuildParameters());
// then
assertThat(future).succeedsWithin(500, TimeUnit.MILLISECONDS);
BuildChangedNotification bcn = future.get();
assertThat(bcn).isNotNull();
assertThat(bcn.getBuild()).isNotNull();
assertThat(bcn.getBuild().getBuildConfigRevision().getId()).isEqualTo(bc.getId());
assertThat(bcn.getBuild().getStatus().isFinal()).isTrue();
wsClient.disconnect();
}
Aggregations