Search in sources :

Example 1 with VariableDocumentRecordValue

use of io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue in project zeebe by camunda.

the class UpdateVariableDocumentProcessorTest method shouldRejectOnMsgpackReadError.

@Test
public void shouldRejectOnMsgpackReadError() {
    // given
    final MutableDirectBuffer badDocument = new UnsafeBuffer(asMsgPack("{\"a\": 1}"));
    // overwrite string header type
    badDocument.putByte(1, (byte) 0);
    final long processInstanceKey = startProcessWithVariables(Map.of());
    // when
    final Record<VariableDocumentRecordValue> result = ENGINE.variables().ofScope(processInstanceKey).withDocument(badDocument).expectRejection().update();
    // then
    assertThat(result).hasRecordType(RecordType.COMMAND_REJECTION).hasRejectionType(RejectionType.INVALID_ARGUMENT);
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) VariableDocumentRecordValue(io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue) Test(org.junit.Test)

Example 2 with VariableDocumentRecordValue

use of io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue in project zeebe by camunda.

the class SetVariablesTest method shouldSetVariables.

@Test
public void shouldSetVariables() {
    // given
    final long processInstanceKey = CLIENT_RULE.createProcessInstance(processDefinitionKey);
    // when
    final SetVariablesResponse response = CLIENT_RULE.getClient().newSetVariablesCommand(processInstanceKey).variables(Map.of("foo", "bar")).send().join();
    // then
    ZeebeAssertHelper.assertVariableDocumentUpdated((variableDocument) -> assertThat(variableDocument.getVariables()).containsOnly(entry("foo", "bar")));
    final Record<VariableDocumentRecordValue> record = RecordingExporter.variableDocumentRecords(VariableDocumentIntent.UPDATED).getFirst();
    assertThat(response.getKey()).isEqualTo(record.getKey());
}
Also used : VariableDocumentRecordValue(io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue) SetVariablesResponse(io.camunda.zeebe.client.api.response.SetVariablesResponse) Test(org.junit.Test)

Example 3 with VariableDocumentRecordValue

use of io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue in project zeebe by camunda-cloud.

the class SetVariablesTest method shouldSetVariables.

@Test
public void shouldSetVariables() {
    // given
    final long processInstanceKey = CLIENT_RULE.createProcessInstance(processDefinitionKey);
    // when
    final SetVariablesResponse response = CLIENT_RULE.getClient().newSetVariablesCommand(processInstanceKey).variables(Map.of("foo", "bar")).send().join();
    // then
    ZeebeAssertHelper.assertVariableDocumentUpdated((variableDocument) -> assertThat(variableDocument.getVariables()).containsOnly(entry("foo", "bar")));
    final Record<VariableDocumentRecordValue> record = RecordingExporter.variableDocumentRecords(VariableDocumentIntent.UPDATED).getFirst();
    assertThat(response.getKey()).isEqualTo(record.getKey());
}
Also used : VariableDocumentRecordValue(io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue) SetVariablesResponse(io.camunda.zeebe.client.api.response.SetVariablesResponse) Test(org.junit.Test)

Example 4 with VariableDocumentRecordValue

use of io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue in project zeebe by zeebe-io.

the class SetVariablesTest method shouldSetVariables.

@Test
public void shouldSetVariables() {
    // given
    final long processInstanceKey = CLIENT_RULE.createProcessInstance(processDefinitionKey);
    // when
    final SetVariablesResponse response = CLIENT_RULE.getClient().newSetVariablesCommand(processInstanceKey).variables(Map.of("foo", "bar")).send().join();
    // then
    ZeebeAssertHelper.assertVariableDocumentUpdated((variableDocument) -> assertThat(variableDocument.getVariables()).containsOnly(entry("foo", "bar")));
    final Record<VariableDocumentRecordValue> record = RecordingExporter.variableDocumentRecords(VariableDocumentIntent.UPDATED).getFirst();
    assertThat(response.getKey()).isEqualTo(record.getKey());
}
Also used : VariableDocumentRecordValue(io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue) SetVariablesResponse(io.camunda.zeebe.client.api.response.SetVariablesResponse) Test(org.junit.Test)

Example 5 with VariableDocumentRecordValue

use of io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue in project zeebe by zeebe-io.

the class UpdateVariableDocumentProcessorTest method shouldRejectOnMsgpackReadError.

@Test
public void shouldRejectOnMsgpackReadError() {
    // given
    final MutableDirectBuffer badDocument = new UnsafeBuffer(asMsgPack("{\"a\": 1}"));
    // overwrite string header type
    badDocument.putByte(1, (byte) 0);
    final long processInstanceKey = startProcessWithVariables(Map.of());
    // when
    final Record<VariableDocumentRecordValue> result = ENGINE.variables().ofScope(processInstanceKey).withDocument(badDocument).expectRejection().update();
    // then
    assertThat(result).hasRecordType(RecordType.COMMAND_REJECTION).hasRejectionType(RejectionType.INVALID_ARGUMENT);
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) VariableDocumentRecordValue(io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue) Test(org.junit.Test)

Aggregations

VariableDocumentRecordValue (io.camunda.zeebe.protocol.record.value.VariableDocumentRecordValue)8 Test (org.junit.Test)7 SetVariablesResponse (io.camunda.zeebe.client.api.response.SetVariablesResponse)3 MutableDirectBuffer (org.agrona.MutableDirectBuffer)3 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)3