use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse in project zeebe by camunda.
the class PublishMessageTest method shouldMapRequestAndResponse.
@Test
public void shouldMapRequestAndResponse() {
// given
final PublishMessageStub stub = new PublishMessageStub();
stub.registerWith(brokerClient);
final String variables = JsonUtil.toJson(Collections.singletonMap("key", "value"));
final PublishMessageRequest request = PublishMessageRequest.newBuilder().setCorrelationKey("correlate").setName("message").setMessageId("unique").setTimeToLive(123).setVariables(variables).build();
// when
final PublishMessageResponse response = client.publishMessage(request);
// then
assertThat(response).isNotNull();
final BrokerPublishMessageRequest brokerRequest = brokerClient.getSingleBrokerRequest();
assertThat(brokerRequest.getIntent()).isEqualTo(MessageIntent.PUBLISH);
assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.MESSAGE);
final MessageRecord brokerRequestValue = brokerRequest.getRequestWriter();
assertThat(bufferAsString(brokerRequestValue.getCorrelationKeyBuffer())).isEqualTo(request.getCorrelationKey());
assertThat(bufferAsString(brokerRequestValue.getNameBuffer())).isEqualTo(request.getName());
assertThat(bufferAsString(brokerRequestValue.getMessageIdBuffer())).isEqualTo(request.getMessageId());
assertThat(brokerRequestValue.getTimeToLive()).isEqualTo(request.getTimeToLive());
MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), variables);
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse in project zeebe by camunda-cloud.
the class PublishMessageTest method shouldMapRequestAndResponse.
@Test
public void shouldMapRequestAndResponse() {
// given
final PublishMessageStub stub = new PublishMessageStub();
stub.registerWith(brokerClient);
final String variables = JsonUtil.toJson(Collections.singletonMap("key", "value"));
final PublishMessageRequest request = PublishMessageRequest.newBuilder().setCorrelationKey("correlate").setName("message").setMessageId("unique").setTimeToLive(123).setVariables(variables).build();
// when
final PublishMessageResponse response = client.publishMessage(request);
// then
assertThat(response).isNotNull();
final BrokerPublishMessageRequest brokerRequest = brokerClient.getSingleBrokerRequest();
assertThat(brokerRequest.getIntent()).isEqualTo(MessageIntent.PUBLISH);
assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.MESSAGE);
final MessageRecord brokerRequestValue = brokerRequest.getRequestWriter();
assertThat(bufferAsString(brokerRequestValue.getCorrelationKeyBuffer())).isEqualTo(request.getCorrelationKey());
assertThat(bufferAsString(brokerRequestValue.getNameBuffer())).isEqualTo(request.getName());
assertThat(bufferAsString(brokerRequestValue.getMessageIdBuffer())).isEqualTo(request.getMessageId());
assertThat(brokerRequestValue.getTimeToLive()).isEqualTo(request.getTimeToLive());
MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), variables);
}
use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse in project zeebe by zeebe-io.
the class PublishMessageTest method shouldMapRequestAndResponse.
@Test
public void shouldMapRequestAndResponse() {
// given
final PublishMessageStub stub = new PublishMessageStub();
stub.registerWith(brokerClient);
final String variables = JsonUtil.toJson(Collections.singletonMap("key", "value"));
final PublishMessageRequest request = PublishMessageRequest.newBuilder().setCorrelationKey("correlate").setName("message").setMessageId("unique").setTimeToLive(123).setVariables(variables).build();
// when
final PublishMessageResponse response = client.publishMessage(request);
// then
assertThat(response).isNotNull();
final BrokerPublishMessageRequest brokerRequest = brokerClient.getSingleBrokerRequest();
assertThat(brokerRequest.getIntent()).isEqualTo(MessageIntent.PUBLISH);
assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.MESSAGE);
final MessageRecord brokerRequestValue = brokerRequest.getRequestWriter();
assertThat(bufferAsString(brokerRequestValue.getCorrelationKeyBuffer())).isEqualTo(request.getCorrelationKey());
assertThat(bufferAsString(brokerRequestValue.getNameBuffer())).isEqualTo(request.getName());
assertThat(bufferAsString(brokerRequestValue.getMessageIdBuffer())).isEqualTo(request.getMessageId());
assertThat(brokerRequestValue.getTimeToLive()).isEqualTo(request.getTimeToLive());
MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), variables);
}
Aggregations