Search in sources :

Example 1 with GroupBuildChangedNotification

use of org.jboss.pnc.dto.notification.GroupBuildChangedNotification in project pnc by project-ncl.

the class DefaultNotifier method collectBuildSetStatusChangedEvent.

public void collectBuildSetStatusChangedEvent(@Observes BuildSetStatusChangedEvent buildSetStatusChangedEvent) {
    logger.trace("Observed new set status changed event {}.", buildSetStatusChangedEvent);
    sendMessage(new GroupBuildChangedNotification(buildSetStatusChangedEvent.getGroupBuild()));
    logger.trace("Set status changed event processed {}.", buildSetStatusChangedEvent);
}
Also used : GroupBuildChangedNotification(org.jboss.pnc.dto.notification.GroupBuildChangedNotification)

Example 2 with GroupBuildChangedNotification

use of org.jboss.pnc.dto.notification.GroupBuildChangedNotification in project pnc by project-ncl.

the class WebSocketClientTest method testRestGroupBuildFallback.

@Test
public void testRestGroupBuildFallback() 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();
    AdvancedGroupConfigurationClient groupConfigurationClient = new AdvancedGroupConfigurationClient(RestClientConfiguration.asUser());
    GroupConfiguration gc = groupConfigurationClient.getAll().iterator().next();
    // test the actual fallbackSupplier (it's private -> reflection unfortunately)
    Method supplier = groupConfigurationClient.getClass().getDeclaredMethod("fallbackSupplier", String.class);
    supplier.setAccessible(true);
    // when
    CompletableFuture<GroupBuildChangedNotification> future = wsClient.catchGroupBuildChangedNotification(() -> invokeMethod(supplier, GroupBuild.class, groupConfigurationClient, gc.getId()), withGConfigId(gc.getId()), withGBuildCompleted());
    GroupBuild groupBuild = groupConfigurationClient.trigger(gc.getId(), new GroupBuildParameters(), GroupBuildRequest.builder().build());
    // wait for GroupBuild to finish
    ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild.getId()), 15, TimeUnit.SECONDS);
    // make client reconnect and use REST fallback
    handler.closeSession();
    // then
    assertThat(future).succeedsWithin(500, TimeUnit.MILLISECONDS);
    wsClient.close();
    wsServer.stop();
}
Also used : GroupBuildChangedNotification(org.jboss.pnc.dto.notification.GroupBuildChangedNotification) GroupBuild(org.jboss.pnc.dto.GroupBuild) AdvancedGroupConfigurationClient(org.jboss.pnc.restclient.AdvancedGroupConfigurationClient) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Method(java.lang.reflect.Method) WebSocketClient(org.jboss.pnc.restclient.websocket.WebSocketClient) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) Undertow(io.undertow.Undertow) VertxWebSocketClient(org.jboss.pnc.restclient.websocket.VertxWebSocketClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

GroupBuildChangedNotification (org.jboss.pnc.dto.notification.GroupBuildChangedNotification)2 Undertow (io.undertow.Undertow)1 Method (java.lang.reflect.Method)1 GroupBuild (org.jboss.pnc.dto.GroupBuild)1 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)1 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)1 AdvancedGroupConfigurationClient (org.jboss.pnc.restclient.AdvancedGroupConfigurationClient)1 VertxWebSocketClient (org.jboss.pnc.restclient.websocket.VertxWebSocketClient)1 WebSocketClient (org.jboss.pnc.restclient.websocket.WebSocketClient)1 ContainerTest (org.jboss.pnc.test.category.ContainerTest)1 Test (org.junit.Test)1