use of org.jboss.pnc.notification.ProgressUpdatesRequest in project pnc by project-ncl.
the class ProcessProgressNotificationTest method shouldSubscribeToProcessUpdatesNotification.
@Test
public void shouldSubscribeToProcessUpdatesNotification() throws Exception {
// given
Integer taskId = 1;
Build build = BuildMock.newBuild(taskId, BuildStatus.SUCCESS, "Build1");
BuildStatusChangedEvent buildStatusChangedEvent = new DefaultBuildStatusChangedEvent(build, BuildStatus.NEW, build.getStatus());
// when
buildStatusNotificationEvent.fire(buildStatusChangedEvent);
ProgressUpdatesRequest progressUpdatesRequest = new ProgressUpdatesRequest(Action.SUBSCRIBE, "component-build", taskId.toString());
String text = JsonOutputConverterMapper.apply(new TypedMessage<>(MessageType.PROCESS_UPDATES, progressUpdatesRequest));
logger.info("Sending test message:" + text);
asyncRemote.sendText(text);
waitForMessages(1);
// then
logger.info("Received: " + notificationCollector.getMessages().get(0));
assertTrue(notificationCollector.getMessages().get(0).startsWith("{\"oldStatus\":\"NEW\",\"build\":{\"id\":\"1\",\"submitTime\":null,\"startTime\":null,\"endTime\":null,\"progress\":null,\"status\":\"SUCCESS\","));
}
use of org.jboss.pnc.notification.ProgressUpdatesRequest in project pnc by project-ncl.
the class WsUpdatesClient method subscribeBlocking.
public void subscribeBlocking(String topic, String filter, Consumer<String> onMessage) throws IOException, DeploymentException {
ProgressUpdatesRequest progressUpdatesRequest = ProgressUpdatesRequest.subscribe(topic, filter);
UpdatesMessageHandler updatesMessageHandler = new UpdatesMessageHandler(onMessage);
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
String uri = "ws://localhost:8080" + NOTIFICATION_PATH;
Session session = container.connectToServer(updatesMessageHandler, URI.create(uri));
RemoteEndpoint.Basic asyncRemote = session.getBasicRemote();
asyncRemote.sendText(toJson(progressUpdatesRequest));
}
Aggregations