Search in sources :

Example 1 with PublishMessageResponse

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);
}
Also used : BrokerPublishMessageRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerPublishMessageRequest) PublishMessageResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse) MessageRecord(io.camunda.zeebe.protocol.impl.record.value.message.MessageRecord) BufferUtil.bufferAsString(io.camunda.zeebe.util.buffer.BufferUtil.bufferAsString) PublishMessageRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageRequest) BrokerPublishMessageRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerPublishMessageRequest) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 2 with PublishMessageResponse

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);
}
Also used : BrokerPublishMessageRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerPublishMessageRequest) PublishMessageResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse) MessageRecord(io.camunda.zeebe.protocol.impl.record.value.message.MessageRecord) BufferUtil.bufferAsString(io.camunda.zeebe.util.buffer.BufferUtil.bufferAsString) PublishMessageRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageRequest) BrokerPublishMessageRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerPublishMessageRequest) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 3 with PublishMessageResponse

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);
}
Also used : BrokerPublishMessageRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerPublishMessageRequest) PublishMessageResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse) MessageRecord(io.camunda.zeebe.protocol.impl.record.value.message.MessageRecord) BufferUtil.bufferAsString(io.camunda.zeebe.util.buffer.BufferUtil.bufferAsString) PublishMessageRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageRequest) BrokerPublishMessageRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerPublishMessageRequest) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Aggregations

GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)3 BrokerPublishMessageRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerPublishMessageRequest)3 PublishMessageRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageRequest)3 PublishMessageResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse)3 MessageRecord (io.camunda.zeebe.protocol.impl.record.value.message.MessageRecord)3 BufferUtil.bufferAsString (io.camunda.zeebe.util.buffer.BufferUtil.bufferAsString)3 Test (org.junit.Test)3