@Test public void shouldApplyPropagateUpdateOperation() { final DirectBuffer variables = asMsgPack("a", 1); final ElementInstance instance = newElementInstance(); final TypedRecord<VariableDocumentRecord> command = newCommand(VariableDocumentRecord.class); command .getValue() .setScopeKey(instance.getKey()) .setUpdateSemantics(VariableDocumentUpdateSemantic.PROPAGATE) .setVariables(variables); processor.onCommand(command, controller); verify(variablesState, times(1)) .setVariablesFromDocument(instance.getKey(), WORKFLOW_KEY, variables); }
@Override public boolean onCommand( final TypedRecord<VariableDocumentRecord> command, final CommandControl<VariableDocumentRecord> controller) { final VariableDocumentRecord record = command.getValue(); final ElementInstance scope = elementInstanceState.getInstance(record.getScopeKey()); if (scope == null || scope.isTerminating() || scope.isInFinalState()) { controller.reject( RejectionType.NOT_FOUND, String.format( "Expected to update variables for element with key '%d', but no such element was found", record.getScopeKey())); return true; } final long workflowKey = scope.getValue().getWorkflowKey(); if (mergeDocument(record, workflowKey, controller)) { controller.accept(VariableDocumentIntent.UPDATED, record); } return true; }
UpdateVariableDocumentProcessor implements CommandProcessor<VariableDocumentRecord> { @Override public boolean onCommand( final TypedRecord<VariableDocumentRecord> command, final CommandControl<VariableDocumentRecord> controller) { final VariableDocumentRecord record = command.getValue(); final ElementInstance scope = elementInstanceState.getInstance(record.getScopeKey()); if (scope == null || scope.isTerminating() || scope.isInFinalState()) { controller.reject( RejectionType.NOT_FOUND, String.format( "Expected to update variables for element with key '%d', but no such element was found", record.getScopeKey())); return true; } final long workflowKey = scope.getValue().getWorkflowKey(); if (mergeDocument(record, workflowKey, controller)) { controller.accept(VariableDocumentIntent.UPDATED, record); } return true; } }
UpdateVariableDocumentProcessor implements CommandProcessor<VariableDocumentRecord> { @Override public boolean onCommand( final TypedRecord<VariableDocumentRecord> command, final CommandControl<VariableDocumentRecord> controller) { final VariableDocumentRecord record = command.getValue(); final ElementInstance scope = elementInstanceState.getInstance(record.getScopeKey()); if (scope == null || scope.isTerminating() || scope.isInFinalState()) { controller.reject( RejectionType.NOT_FOUND, String.format( "Expected to update variables for element with key '%d', but no such element was found", record.getScopeKey())); return true; } final long workflowKey = scope.getValue().getWorkflowKey(); if (mergeDocument(record, workflowKey, controller)) { controller.accept(VariableDocumentIntent.UPDATED, record); } return true; } UpdateVariableDocumentProcessor(
      final ElementInstanceState elementInstanceState, final VariablesState variablesState); }
UpdateVariableDocumentProcessor implements CommandProcessor<VariableDocumentRecord> { @Override public boolean onCommand( final TypedRecord<VariableDocumentRecord> command, final CommandControl<VariableDocumentRecord> controller) { final VariableDocumentRecord record = command.getValue(); final ElementInstance scope = elementInstanceState.getInstance(record.getScopeKey()); if (scope == null || scope.isTerminating() || scope.isInFinalState()) { controller.reject( RejectionType.NOT_FOUND, String.format( "Expected to update variables for element with key '%d', but no such element was found", record.getScopeKey())); return true; } final long workflowKey = scope.getValue().getWorkflowKey(); if (mergeDocument(record, workflowKey, controller)) { controller.accept(VariableDocumentIntent.UPDATED, record); } return true; } UpdateVariableDocumentProcessor(
      final ElementInstanceState elementInstanceState, final VariablesState variablesState); @Override boolean onCommand(
      final TypedRecord<VariableDocumentRecord> command,
      final CommandControl<VariableDocumentRecord> controller); }
UpdateVariableDocumentProcessor implements CommandProcessor<VariableDocumentRecord> { @Override public boolean onCommand( final TypedRecord<VariableDocumentRecord> command, final CommandControl<VariableDocumentRecord> controller) { final VariableDocumentRecord record = command.getValue(); final ElementInstance scope = elementInstanceState.getInstance(record.getScopeKey()); if (scope == null || scope.isTerminating() || scope.isInFinalState()) { controller.reject( RejectionType.NOT_FOUND, String.format( "Expected to update variables for element with key '%d', but no such element was found", record.getScopeKey())); return true; } final long workflowKey = scope.getValue().getWorkflowKey(); if (mergeDocument(record, workflowKey, controller)) { controller.accept(VariableDocumentIntent.UPDATED, record); } return true; } UpdateVariableDocumentProcessor(
      final ElementInstanceState elementInstanceState, final VariablesState variablesState); @Override boolean onCommand(
      final TypedRecord<VariableDocumentRecord> command,
      final CommandControl<VariableDocumentRecord> controller);  }