Search in sources :

Example 1 with SetVariablesResponse

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse in project zeebe by zeebe-io.

the class SetVariablesTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final SetVariablesStub stub = new SetVariablesStub();
    stub.registerWith(brokerClient);
    final String variables = JsonUtil.toJson(Collections.singletonMap("key", "value"));
    final int partitionId = 1;
    final long elementInstanceKey = Protocol.encodePartitionId(partitionId, 1);
    final SetVariablesRequest request = SetVariablesRequest.newBuilder().setElementInstanceKey(elementInstanceKey).setVariables(variables).build();
    // when
    final SetVariablesResponse response = client.setVariables(request);
    // then
    assertThat(response).isNotNull();
    assertThat(response.getKey()).isEqualTo(stub.getKey());
    final BrokerSetVariablesRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    assertThat(brokerRequest.getKey()).isEqualTo(-1);
    assertThat(brokerRequest.getIntent()).isEqualTo(VariableDocumentIntent.UPDATE);
    assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.VARIABLE_DOCUMENT);
    assertThat(brokerRequest.getPartitionId()).isEqualTo(partitionId);
    final VariableDocumentRecord brokerRequestValue = brokerRequest.getRequestWriter();
    MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), variables);
    assertThat(brokerRequestValue.getScopeKey()).isEqualTo(elementInstanceKey);
}
Also used : BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) SetVariablesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesRequest) BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) VariableDocumentRecord(io.camunda.zeebe.protocol.impl.record.value.variable.VariableDocumentRecord) SetVariablesResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 2 with SetVariablesResponse

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse in project zeebe by camunda-cloud.

the class SetVariablesTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final SetVariablesStub stub = new SetVariablesStub();
    stub.registerWith(brokerClient);
    final String variables = JsonUtil.toJson(Collections.singletonMap("key", "value"));
    final int partitionId = 1;
    final long elementInstanceKey = Protocol.encodePartitionId(partitionId, 1);
    final SetVariablesRequest request = SetVariablesRequest.newBuilder().setElementInstanceKey(elementInstanceKey).setVariables(variables).build();
    // when
    final SetVariablesResponse response = client.setVariables(request);
    // then
    assertThat(response).isNotNull();
    assertThat(response.getKey()).isEqualTo(stub.getKey());
    final BrokerSetVariablesRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    assertThat(brokerRequest.getKey()).isEqualTo(-1);
    assertThat(brokerRequest.getIntent()).isEqualTo(VariableDocumentIntent.UPDATE);
    assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.VARIABLE_DOCUMENT);
    assertThat(brokerRequest.getPartitionId()).isEqualTo(partitionId);
    final VariableDocumentRecord brokerRequestValue = brokerRequest.getRequestWriter();
    MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), variables);
    assertThat(brokerRequestValue.getScopeKey()).isEqualTo(elementInstanceKey);
}
Also used : BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) SetVariablesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesRequest) BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) VariableDocumentRecord(io.camunda.zeebe.protocol.impl.record.value.variable.VariableDocumentRecord) SetVariablesResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Example 3 with SetVariablesResponse

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse in project zeebe by camunda.

the class SetVariablesTest method shouldMapRequestAndResponse.

@Test
public void shouldMapRequestAndResponse() {
    // given
    final SetVariablesStub stub = new SetVariablesStub();
    stub.registerWith(brokerClient);
    final String variables = JsonUtil.toJson(Collections.singletonMap("key", "value"));
    final int partitionId = 1;
    final long elementInstanceKey = Protocol.encodePartitionId(partitionId, 1);
    final SetVariablesRequest request = SetVariablesRequest.newBuilder().setElementInstanceKey(elementInstanceKey).setVariables(variables).build();
    // when
    final SetVariablesResponse response = client.setVariables(request);
    // then
    assertThat(response).isNotNull();
    assertThat(response.getKey()).isEqualTo(stub.getKey());
    final BrokerSetVariablesRequest brokerRequest = brokerClient.getSingleBrokerRequest();
    assertThat(brokerRequest.getKey()).isEqualTo(-1);
    assertThat(brokerRequest.getIntent()).isEqualTo(VariableDocumentIntent.UPDATE);
    assertThat(brokerRequest.getValueType()).isEqualTo(ValueType.VARIABLE_DOCUMENT);
    assertThat(brokerRequest.getPartitionId()).isEqualTo(partitionId);
    final VariableDocumentRecord brokerRequestValue = brokerRequest.getRequestWriter();
    MsgPackUtil.assertEqualityExcluding(brokerRequestValue.getVariablesBuffer(), variables);
    assertThat(brokerRequestValue.getScopeKey()).isEqualTo(elementInstanceKey);
}
Also used : BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) SetVariablesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesRequest) BrokerSetVariablesRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest) VariableDocumentRecord(io.camunda.zeebe.protocol.impl.record.value.variable.VariableDocumentRecord) SetVariablesResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse) GatewayTest(io.camunda.zeebe.gateway.api.util.GatewayTest) Test(org.junit.Test)

Aggregations

GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)3 BrokerSetVariablesRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerSetVariablesRequest)3 SetVariablesRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesRequest)3 SetVariablesResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse)3 VariableDocumentRecord (io.camunda.zeebe.protocol.impl.record.value.variable.VariableDocumentRecord)3 Test (org.junit.Test)3