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);
}
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);
}
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);
}
Aggregations