Search in sources :

Example 1 with CamundaValue

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

the class CamundaValueImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(CamundaValue.class, CAMUNDA_ELEMENT_VALUE).namespaceUri(CAMUNDA_NS).instanceProvider(new ModelTypeInstanceProvider<CamundaValue>() {

        public CamundaValue newInstance(ModelTypeInstanceContext instanceContext) {
            return new CamundaValueImpl(instanceContext);
        }
    });
    camundaIdAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_ID).namespace(CAMUNDA_NS).build();
    camundaNameAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_NAME).namespace(CAMUNDA_NS).build();
    typeBuilder.build();
}
Also used : ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext) CamundaValue(org.camunda.bpm.model.bpmn.instance.camunda.CamundaValue)

Example 2 with CamundaValue

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

the class CamundaExtensionsTest method testFormData.

@Test
public void testFormData() {
    CamundaFormData formData = userTask.getExtensionElements().getElementsQuery().filterByType(CamundaFormData.class).singleResult();
    CamundaFormField formField = formData.getCamundaFormFields().iterator().next();
    assertThat(formField.getCamundaId()).isEqualTo(TEST_STRING_XML);
    assertThat(formField.getCamundaLabel()).isEqualTo(TEST_STRING_XML);
    assertThat(formField.getCamundaType()).isEqualTo(TEST_STRING_XML);
    assertThat(formField.getCamundaDatePattern()).isEqualTo(TEST_STRING_XML);
    assertThat(formField.getCamundaDefaultValue()).isEqualTo(TEST_STRING_XML);
    formField.setCamundaId(TEST_STRING_API);
    formField.setCamundaLabel(TEST_STRING_API);
    formField.setCamundaType(TEST_STRING_API);
    formField.setCamundaDatePattern(TEST_STRING_API);
    formField.setCamundaDefaultValue(TEST_STRING_API);
    assertThat(formField.getCamundaId()).isEqualTo(TEST_STRING_API);
    assertThat(formField.getCamundaLabel()).isEqualTo(TEST_STRING_API);
    assertThat(formField.getCamundaType()).isEqualTo(TEST_STRING_API);
    assertThat(formField.getCamundaDatePattern()).isEqualTo(TEST_STRING_API);
    assertThat(formField.getCamundaDefaultValue()).isEqualTo(TEST_STRING_API);
    CamundaProperty property = formField.getCamundaProperties().getCamundaProperties().iterator().next();
    assertThat(property.getCamundaId()).isEqualTo(TEST_STRING_XML);
    assertThat(property.getCamundaValue()).isEqualTo(TEST_STRING_XML);
    property.setCamundaId(TEST_STRING_API);
    property.setCamundaValue(TEST_STRING_API);
    assertThat(property.getCamundaId()).isEqualTo(TEST_STRING_API);
    assertThat(property.getCamundaValue()).isEqualTo(TEST_STRING_API);
    CamundaConstraint constraint = formField.getCamundaValidation().getCamundaConstraints().iterator().next();
    assertThat(constraint.getCamundaName()).isEqualTo(TEST_STRING_XML);
    assertThat(constraint.getCamundaConfig()).isEqualTo(TEST_STRING_XML);
    constraint.setCamundaName(TEST_STRING_API);
    constraint.setCamundaConfig(TEST_STRING_API);
    assertThat(constraint.getCamundaName()).isEqualTo(TEST_STRING_API);
    assertThat(constraint.getCamundaConfig()).isEqualTo(TEST_STRING_API);
    CamundaValue value = formField.getCamundaValues().iterator().next();
    assertThat(value.getCamundaId()).isEqualTo(TEST_STRING_XML);
    assertThat(value.getCamundaName()).isEqualTo(TEST_STRING_XML);
    value.setCamundaId(TEST_STRING_API);
    value.setCamundaName(TEST_STRING_API);
    assertThat(value.getCamundaId()).isEqualTo(TEST_STRING_API);
    assertThat(value.getCamundaName()).isEqualTo(TEST_STRING_API);
}
Also used : CamundaFormData(org.camunda.bpm.model.bpmn.instance.camunda.CamundaFormData) CamundaProperty(org.camunda.bpm.model.bpmn.instance.camunda.CamundaProperty) CamundaConstraint(org.camunda.bpm.model.bpmn.instance.camunda.CamundaConstraint) CamundaFormField(org.camunda.bpm.model.bpmn.instance.camunda.CamundaFormField) CamundaValue(org.camunda.bpm.model.bpmn.instance.camunda.CamundaValue) Test(org.junit.Test)

Example 3 with CamundaValue

use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaValue 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)

Aggregations

CamundaValue (org.camunda.bpm.model.bpmn.instance.camunda.CamundaValue)3 CamundaConstraint (org.camunda.bpm.model.bpmn.instance.camunda.CamundaConstraint)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 BpmnModelElementInstance (org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance)1 CamundaFormData (org.camunda.bpm.model.bpmn.instance.camunda.CamundaFormData)1 CamundaFormField (org.camunda.bpm.model.bpmn.instance.camunda.CamundaFormField)1 CamundaInputParameter (org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter)1 CamundaList (org.camunda.bpm.model.bpmn.instance.camunda.CamundaList)1 CamundaProperty (org.camunda.bpm.model.bpmn.instance.camunda.CamundaProperty)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1