コード例 #1
0
  @Test
  @DiagramResource(
      "org/camunda/bpm/modeler/test/core/utils/ExtensionUtilTest.testAddAndRemoveExtensions.bpmn")
  public void testAddAndRemoveExtensionsToOutType() {
    final CallActivity callActivity =
        findBusinessObjectById(diagram, "callActivity", CallActivity.class);

    List<ExtensionAttributeValue> extensionAttributeValues =
        ExtensionUtil.getExtensionAttributeValues(callActivity);
    assertThat(extensionAttributeValues).hasSize(0);

    // add <camunda:out source="test" target="test"/>
    final OutType sourceOutType = modelFactory.createOutType();
    sourceOutType.setSource("test");
    sourceOutType.setTarget("test");

    addCallActivityExtension(callActivity, CALL_ACTIVITY_OUT_TYPE, sourceOutType);

    Object value = ExtensionUtil.getExtension(callActivity, CALL_ACTIVITY_OUT_TYPE, "source");
    assertThat(value).isEqualTo("test");

    // add <camunda:out source="test2" target="test2"/>
    final OutType source2OutType = modelFactory.createOutType();
    source2OutType.setSource("test2");
    source2OutType.setTarget("test2");

    addCallActivityExtension(callActivity, CALL_ACTIVITY_OUT_TYPE, source2OutType);

    // add <camunda:out variables="all"/>
    final OutType variablesOutType = modelFactory.createOutType();
    variablesOutType.setVariables(ALL_VARIABLES_VALUE);

    addCallActivityExtension(callActivity, CALL_ACTIVITY_OUT_TYPE, variablesOutType);

    value = ExtensionUtil.getExtension(callActivity, CALL_ACTIVITY_OUT_TYPE, "variables");
    assertThat(value).isEqualTo(ALL_VARIABLES_VALUE);

    List<OutType> extensions = ExtensionUtil.getExtensions(callActivity, OutType.class);
    assertThat(extensions).hasSize(3);

    // remove outType source="test2" extension
    transactionalExecute(
        new RecordingCommand(editingDomain) {

          @Override
          protected void doExecute() {
            ExtensionUtil.removeExtensionByValue(
                callActivity, CALL_ACTIVITY_OUT_TYPE, OUT_TYPE_SOURCE, "test2");
          }
        });

    extensions = ExtensionUtil.getExtensions(callActivity, OutType.class);
    assertThat(extensions).hasSize(2);

    value = ExtensionUtil.getExtension(callActivity, CALL_ACTIVITY_OUT_TYPE, "source");
    assertThat(value).isEqualTo("test");

    extensionAttributeValues = ExtensionUtil.getExtensionAttributeValues(callActivity);
    assertThat(extensionAttributeValues).hasSize(1);
  }
コード例 #2
0
  @Test
  @DiagramResource(
      "org/camunda/bpm/modeler/test/ui/change/FieldInjectionAddElementToExtension.bpmn")
  public void testAddFieldElementOnlyWithNameToExistingFieldsWithAttributes() {
    final ServiceTask serviceTask =
        findBusinessObjectById(diagram, "ServiceTask_1", ServiceTask.class);

    List<FieldType> fieldTypeList = ExtensionUtil.getExtensions(serviceTask, FieldType.class);
    assertThat(fieldTypeList).hasSize(2);

    final FieldType fieldType = modelFactory.createFieldType();
    fieldType.setName("myFieldElement");

    ExtensionChangeFilter filter = new ExtensionChangeFilter(serviceTask, FIELD_TYPE_FEATURE);
    CustomResourceSetListener listener = new CustomResourceSetListener(serviceTask, filter);
    listener.register();

    transactionalExecute(
        new RecordingCommand(editingDomain) {

          @Override
          protected void doExecute() {
            ExtensionUtil.addExtension(serviceTask, FIELD_TYPE_FEATURE, fieldType);
          }
        });

    assertThat(listener.getCapturedEvents()).hasSize(1);

    fieldTypeList = ExtensionUtil.getExtensions(serviceTask, FieldType.class);
    assertThat(fieldTypeList).hasSize(3);
  }
コード例 #3
0
  public InType addCallActivityInType(final CallActivity callActivity) {
    final InType inType = modelFactory.createInType();
    inType.setSource("ASD");

    transactionalExecute(
        new RecordingCommand(editingDomain) {

          @Override
          protected void doExecute() {
            ExtensionUtil.addExtension(callActivity, IN_FEATURE, inType);
          }
        });

    return inType;
  }
コード例 #4
0
  @Test
  @DiagramResource(
      "org/camunda/bpm/modeler/test/core/utils/ExtensionUtilTest.testAddAndRemoveExtensions.bpmn")
  public void testAddAndRemoveExtensionsToInType() {
    final CallActivity callActivity =
        findBusinessObjectById(diagram, "callActivity", CallActivity.class);

    List<ExtensionAttributeValue> extensionAttributeValues =
        ExtensionUtil.getExtensionAttributeValues(callActivity);
    assertThat(extensionAttributeValues).hasSize(0);

    // add <camunda:in source="test" target="test"/>
    final InType sourceInType = modelFactory.createInType();
    sourceInType.setSource("test");
    sourceInType.setTarget("test");

    addCallActivityExtension(callActivity, CALL_ACTIVITY_IN_TYPE, sourceInType);

    Object value = ExtensionUtil.getExtension(callActivity, CALL_ACTIVITY_IN_TYPE, "source");
    assertThat(value).isEqualTo("test");

    // add <camunda:in source="test2" target="test2"/>
    final InType source2InType = modelFactory.createInType();
    source2InType.setSource("test2");
    source2InType.setTarget("test2");

    addCallActivityExtension(callActivity, CALL_ACTIVITY_IN_TYPE, source2InType);

    // add <camunda:in businessKey="#{execution.processBusinessKey}"/>
    final InType businessKeyInType = modelFactory.createInType();
    businessKeyInType.setBusinessKey(BUSINESS_KEY_EXPRESSION);

    addCallActivityExtension(callActivity, CALL_ACTIVITY_IN_TYPE, businessKeyInType);

    value = ExtensionUtil.getExtension(callActivity, CALL_ACTIVITY_IN_TYPE, "businessKey");
    assertThat(value).isEqualTo(BUSINESS_KEY_EXPRESSION);

    // add <camunda:in variables="all"/>
    final InType variablesInType = modelFactory.createInType();
    variablesInType.setVariables(ALL_VARIABLES_VALUE);

    addCallActivityExtension(callActivity, CALL_ACTIVITY_IN_TYPE, variablesInType);

    value = ExtensionUtil.getExtension(callActivity, CALL_ACTIVITY_IN_TYPE, "variables");
    assertThat(value).isEqualTo(ALL_VARIABLES_VALUE);

    List<InType> extensions = ExtensionUtil.getExtensions(callActivity, InType.class);
    assertThat(extensions).hasSize(4);

    // remove inType businessKey extension
    transactionalExecute(
        new RecordingCommand(editingDomain) {

          @Override
          protected void doExecute() {
            ExtensionUtil.removeExtensionByValue(
                callActivity, CALL_ACTIVITY_IN_TYPE, IN_TYPE_BUSINESS_KEY, BUSINESS_KEY_EXPRESSION);
          }
        });

    extensions = ExtensionUtil.getExtensions(callActivity, InType.class);
    assertThat(extensions).hasSize(3);

    value = ExtensionUtil.getExtension(callActivity, CALL_ACTIVITY_IN_TYPE, "businessKey");
    assertThat(value).isNull();

    extensionAttributeValues = ExtensionUtil.getExtensionAttributeValues(callActivity);
    assertThat(extensionAttributeValues).hasSize(1);
  }