Search in sources :

Example 1 with CamundaInputParameter

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter in project camunda-bpmn-model by camunda.

the class CamundaExtensionsTest method testCamundaInputParameter.

@Test
public void testCamundaInputParameter() {
    // find existing
    CamundaInputParameter inputParameter = findInputParameterByName(serviceTask, "shouldBeConstant");
    // modify existing
    inputParameter.setCamundaName("hello");
    inputParameter.setTextContent("world");
    inputParameter = findInputParameterByName(serviceTask, "hello");
    assertThat(inputParameter.getTextContent()).isEqualTo("world");
    // add new one
    inputParameter = modelInstance.newInstance(CamundaInputParameter.class);
    inputParameter.setCamundaName("abc");
    inputParameter.setTextContent("def");
    serviceTask.getExtensionElements().getElementsQuery().filterByType(CamundaInputOutput.class).singleResult().addChildElement(inputParameter);
    // search for new one
    inputParameter = findInputParameterByName(serviceTask, "abc");
    assertThat(inputParameter.getCamundaName()).isEqualTo("abc");
    assertThat(inputParameter.getTextContent()).isEqualTo("def");
}
Also used : CamundaInputParameter(org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter) Test(org.junit.Test)

Example 2 with CamundaInputParameter

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter in project camunda-bpmn-model by camunda.

the class CamundaExtensionsTest method testCamundaNullInputParameter.

@Test
public void testCamundaNullInputParameter() {
    CamundaInputParameter inputParameter = findInputParameterByName(serviceTask, "shouldBeNull");
    assertThat(inputParameter.getCamundaName()).isEqualTo("shouldBeNull");
    assertThat(inputParameter.getTextContent()).isEmpty();
}
Also used : CamundaInputParameter(org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter) Test(org.junit.Test)

Example 3 with CamundaInputParameter

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter in project camunda-bpmn-model by camunda.

the class CamundaExtensionsTest method testCamundaExpressionInputParameter.

@Test
public void testCamundaExpressionInputParameter() {
    CamundaInputParameter inputParameter = findInputParameterByName(serviceTask, "shouldBeExpression");
    assertThat(inputParameter.getCamundaName()).isEqualTo("shouldBeExpression");
    assertThat(inputParameter.getTextContent()).isEqualTo("${1 + 1}");
}
Also used : CamundaInputParameter(org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter) Test(org.junit.Test)

Example 4 with CamundaInputParameter

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter in project camunda-bpmn-model by camunda.

the class CamundaExtensionsTest method testCamundaListInputParameter.

@Test
public void testCamundaListInputParameter() {
    CamundaInputParameter inputParameter = findInputParameterByName(serviceTask, "shouldBeList");
    assertThat(inputParameter.getCamundaName()).isEqualTo("shouldBeList");
    assertThat(inputParameter.getTextContent()).isNotEmpty();
    assertThat(inputParameter.getUniqueChildElementByNameNs(CAMUNDA_NS, "list")).isNotNull();
    CamundaList list = inputParameter.getValue();
    assertThat(list.getValues()).hasSize(3);
    for (BpmnModelElementInstance values : list.getValues()) {
        assertThat(values.getTextContent()).isIn("a", "b", "c");
    }
    list = modelInstance.newInstance(CamundaList.class);
    for (int i = 0; i < 4; i++) {
        CamundaValue value = modelInstance.newInstance(CamundaValue.class);
        value.setTextContent("test");
        list.getValues().add(value);
    }
    Collection<CamundaValue> testValues = Arrays.asList(modelInstance.newInstance(CamundaValue.class), modelInstance.newInstance(CamundaValue.class));
    list.getValues().addAll(testValues);
    inputParameter.setValue(list);
    list = inputParameter.getValue();
    assertThat(list.getValues()).hasSize(6);
    list.getValues().removeAll(testValues);
    ArrayList<BpmnModelElementInstance> camundaValues = new ArrayList<BpmnModelElementInstance>(list.getValues());
    assertThat(camundaValues).hasSize(4);
    for (BpmnModelElementInstance value : camundaValues) {
        assertThat(value.getTextContent()).isEqualTo("test");
    }
    list.getValues().remove(camundaValues.get(1));
    assertThat(list.getValues()).hasSize(3);
    list.getValues().removeAll(Arrays.asList(camundaValues.get(0), camundaValues.get(3)));
    assertThat(list.getValues()).hasSize(1);
    list.getValues().clear();
    assertThat(list.getValues()).isEmpty();
    // test standard list interactions
    Collection<BpmnModelElementInstance> elements = list.getValues();
    CamundaValue value = modelInstance.newInstance(CamundaValue.class);
    elements.add(value);
    List<CamundaValue> newValues = new ArrayList<CamundaValue>();
    newValues.add(modelInstance.newInstance(CamundaValue.class));
    newValues.add(modelInstance.newInstance(CamundaValue.class));
    elements.addAll(newValues);
    assertThat(elements).hasSize(3);
    assertThat(elements).doesNotContain(modelInstance.newInstance(CamundaValue.class));
    assertThat(elements.containsAll(Arrays.asList(modelInstance.newInstance(CamundaValue.class)))).isFalse();
    assertThat(elements.remove(modelInstance.newInstance(CamundaValue.class))).isFalse();
    assertThat(elements).hasSize(3);
    assertThat(elements.remove(value)).isTrue();
    assertThat(elements).hasSize(2);
    assertThat(elements.removeAll(newValues)).isTrue();
    assertThat(elements).isEmpty();
    elements.add(modelInstance.newInstance(CamundaValue.class));
    elements.clear();
    assertThat(elements).isEmpty();
    inputParameter.removeValue();
    assertThat(inputParameter.getValue()).isNull();
}
Also used : BpmnModelElementInstance(org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance) ArrayList(java.util.ArrayList) CamundaInputParameter(org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter) CamundaList(org.camunda.bpm.model.bpmn.instance.camunda.CamundaList) CamundaConstraint(org.camunda.bpm.model.bpmn.instance.camunda.CamundaConstraint) CamundaValue(org.camunda.bpm.model.bpmn.instance.camunda.CamundaValue) Test(org.junit.Test)

Example 5 with CamundaInputParameter

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter in project camunda-bpmn-model by camunda.

the class CamundaExtensionsTest method testCamundaScriptInputParameter.

@Test
public void testCamundaScriptInputParameter() {
    CamundaInputParameter inputParameter = findInputParameterByName(serviceTask, "shouldBeScript");
    assertThat(inputParameter.getCamundaName()).isEqualTo("shouldBeScript");
    assertThat(inputParameter.getTextContent()).isNotEmpty();
    assertThat(inputParameter.getUniqueChildElementByNameNs(CAMUNDA_NS, "script")).isNotNull();
    assertThat(inputParameter.getUniqueChildElementByType(CamundaScript.class)).isNotNull();
    CamundaScript script = inputParameter.getValue();
    assertThat(script.getCamundaScriptFormat()).isEqualTo("groovy");
    assertThat(script.getCamundaResource()).isNull();
    assertThat(script.getTextContent()).isEqualTo("1 + 1");
    script = modelInstance.newInstance(CamundaScript.class);
    script.setCamundaScriptFormat("python");
    script.setCamundaResource("script.py");
    inputParameter.setValue(script);
    script = inputParameter.getValue();
    assertThat(script.getCamundaScriptFormat()).isEqualTo("python");
    assertThat(script.getCamundaResource()).isEqualTo("script.py");
    assertThat(script.getTextContent()).isEmpty();
    inputParameter.removeValue();
    assertThat(inputParameter.getValue()).isNull();
}
Also used : CamundaInputParameter(org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter) CamundaScript(org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript) Test(org.junit.Test)

Aggregations

CamundaInputParameter (org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter)12 Test (org.junit.Test)8 CamundaInputOutput (org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputOutput)4 ArrayList (java.util.ArrayList)2 CamundaOutputParameter (org.camunda.bpm.model.bpmn.instance.camunda.CamundaOutputParameter)2 BpmnModelElementInstance (org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance)1 CamundaConnector (org.camunda.bpm.model.bpmn.instance.camunda.CamundaConnector)1 CamundaConnectorId (org.camunda.bpm.model.bpmn.instance.camunda.CamundaConnectorId)1 CamundaConstraint (org.camunda.bpm.model.bpmn.instance.camunda.CamundaConstraint)1 CamundaEntry (org.camunda.bpm.model.bpmn.instance.camunda.CamundaEntry)1 CamundaList (org.camunda.bpm.model.bpmn.instance.camunda.CamundaList)1 CamundaMap (org.camunda.bpm.model.bpmn.instance.camunda.CamundaMap)1 CamundaScript (org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript)1 CamundaValue (org.camunda.bpm.model.bpmn.instance.camunda.CamundaValue)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1