use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandlerTest method testHandleStartMessageBrokerAvailableDataNullSendError.
@Test
public void testHandleStartMessageBrokerAvailableDataNullSendError() {
// given
Message<GraphQLMessage> message = startMessage("id", "sess1");
ExecutionResult executionResult = mock(ExecutionResult.class);
when(graphQLExecutor.execute(anyString(), any())).thenReturn(executionResult);
when(executionResult.getErrors()).thenReturn(Collections.emptyList());
when(executionResult.getData()).thenReturn(null);
// when
this.messageHandler.handleMessage(message);
// then
verify(this.clientOutboundChannel).send(this.messageCaptor.capture());
assertThat(messageCaptor.getValue().getPayload()).isInstanceOf(GraphQLMessage.class);
assertThat(messageCaptor.getValue().getPayload().getType()).isEqualTo(GraphQLMessageType.ERROR);
assertThat(messageCaptor.getValue().getPayload().getId()).isEqualTo("id");
assertThat(messageCaptor.getValue().getPayload().getPayload()).containsKey("errors");
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandlerTest method testHandleStopMessageCompletesSubscriber.
@Test
public void testHandleStopMessageCompletesSubscriber() {
// given
Message<GraphQLMessage> message = stopMessage("subscriptionId", "sessionId");
GraphQLBrokerChannelSubscriber subscriber = mock(GraphQLBrokerChannelSubscriber.class);
GraphQLBrokerSubscriptionRegistry registry = messageHandler.getGraphQLsubscriptionRegistry();
registry.subscribe("sessionId", "subscriptionId", subscriber);
// when
this.messageHandler.handleMessage(message);
// then
verify(subscriber).onComplete();
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandlerTest method connectionInitMessage.
private Message<GraphQLMessage> connectionInitMessage(String operationId, String sessionId) {
SimpMessageHeaderAccessor headerAccessor = simpHeaderAccessor(mockWebSocketSession(sessionId));
headerAccessor.setHeader(StompHeaderAccessor.HEART_BEAT_HEADER, new long[] { 0, 5000 });
GraphQLMessage payload = new GraphQLMessage(operationId, GraphQLMessageType.CONNECTION_INIT);
return MessageBuilder.createMessage(payload, headerAccessor.getMessageHeaders());
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandlerTest method testHandleStartMessageBrokerUnavailableSendsError.
@Test
public void testHandleStartMessageBrokerUnavailableSendsError() {
// given
this.messageHandler.on(new BrokerAvailabilityEvent(false, this));
Message<GraphQLMessage> message = startMessage("id", "sess1");
// when
this.messageHandler.handleMessage(message);
// then
verify(this.clientOutboundChannel).send(this.messageCaptor.capture());
assertThat(messageCaptor.getValue().getPayload()).isInstanceOf(GraphQLMessage.class);
assertThat(messageCaptor.getValue().getPayload().getType()).isEqualTo(GraphQLMessageType.ERROR);
assertThat(messageCaptor.getValue().getPayload().getId()).isEqualTo("id");
assertThat(messageCaptor.getValue().getPayload().getPayload()).containsKey("errors");
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandlerTest method testHandleStartMessageBrokerAvailableExecutorErrorSendsError.
@Test
public void testHandleStartMessageBrokerAvailableExecutorErrorSendsError() {
// given
Message<GraphQLMessage> message = startMessage("id", "sess1");
ExecutionResult executionResult = mock(ExecutionResult.class);
when(graphQLExecutor.execute(anyString(), any())).thenReturn(executionResult);
when(executionResult.getErrors()).thenReturn(Collections.singletonList(mock(GraphQLError.class)));
when(executionResult.getData()).thenReturn(null);
// when
this.messageHandler.handleMessage(message);
// then
verify(this.clientOutboundChannel).send(this.messageCaptor.capture());
assertThat(messageCaptor.getValue().getPayload()).isInstanceOf(GraphQLMessage.class);
assertThat(messageCaptor.getValue().getPayload().getType()).isEqualTo(GraphQLMessageType.ERROR);
assertThat(messageCaptor.getValue().getPayload().getId()).isEqualTo("id");
assertThat(messageCaptor.getValue().getPayload().getPayload()).containsKey("errors");
}
Aggregations