use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaMap in project camunda-bpmn-model by camunda.
the class CamundaExtensionsTest method testCamundaMapInputParameter.
@Test
public void testCamundaMapInputParameter() {
CamundaInputParameter inputParameter = findInputParameterByName(serviceTask, "shouldBeMap");
assertThat(inputParameter.getCamundaName()).isEqualTo("shouldBeMap");
assertThat(inputParameter.getTextContent()).isNotEmpty();
assertThat(inputParameter.getUniqueChildElementByNameNs(CAMUNDA_NS, "map")).isNotNull();
CamundaMap map = inputParameter.getValue();
assertThat(map.getCamundaEntries()).hasSize(2);
for (CamundaEntry entry : map.getCamundaEntries()) {
if (entry.getCamundaKey().equals("foo")) {
assertThat(entry.getTextContent()).isEqualTo("bar");
} else {
assertThat(entry.getCamundaKey()).isEqualTo("hello");
assertThat(entry.getTextContent()).isEqualTo("world");
}
}
map = modelInstance.newInstance(CamundaMap.class);
CamundaEntry entry = modelInstance.newInstance(CamundaEntry.class);
entry.setCamundaKey("test");
entry.setTextContent("value");
map.getCamundaEntries().add(entry);
inputParameter.setValue(map);
map = inputParameter.getValue();
assertThat(map.getCamundaEntries()).hasSize(1);
entry = map.getCamundaEntries().iterator().next();
assertThat(entry.getCamundaKey()).isEqualTo("test");
assertThat(entry.getTextContent()).isEqualTo("value");
Collection<CamundaEntry> entries = map.getCamundaEntries();
entries.add(modelInstance.newInstance(CamundaEntry.class));
assertThat(entries).hasSize(2);
inputParameter.removeValue();
assertThat(inputParameter.getValue()).isNull();
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaMap in project camunda-bpmn-model by camunda.
the class CamundaMapImpl method registerType.
public static void registerType(ModelBuilder modelBuilder) {
ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(CamundaMap.class, BpmnModelConstants.CAMUNDA_ELEMENT_MAP).namespaceUri(CAMUNDA_NS).instanceProvider(new ModelTypeInstanceProvider<CamundaMap>() {
public CamundaMap newInstance(ModelTypeInstanceContext instanceContext) {
return new CamundaMapImpl(instanceContext);
}
});
SequenceBuilder sequenceBuilder = typeBuilder.sequence();
camundaEntryCollection = sequenceBuilder.elementCollection(CamundaEntry.class).build();
typeBuilder.build();
}
use of org.camunda.bpm.model.bpmn.instance.camunda.CamundaMap in project camunda-bpmn-model by camunda.
the class CamundaExtensionsTest method testCamundaNestedOutputParameter.
@Test
public void testCamundaNestedOutputParameter() {
CamundaOutputParameter camundaOutputParameter = serviceTask.getExtensionElements().getElementsQuery().filterByType(CamundaInputOutput.class).singleResult().getCamundaOutputParameters().iterator().next();
assertThat(camundaOutputParameter).isNotNull();
assertThat(camundaOutputParameter.getCamundaName()).isEqualTo("nested");
CamundaList list = camundaOutputParameter.getValue();
assertThat(list).isNotNull();
assertThat(list.getValues()).hasSize(2);
Iterator<BpmnModelElementInstance> iterator = list.getValues().iterator();
// nested list
CamundaList nestedList = (CamundaList) iterator.next().getUniqueChildElementByType(CamundaList.class);
assertThat(nestedList).isNotNull();
assertThat(nestedList.getValues()).hasSize(2);
for (BpmnModelElementInstance value : nestedList.getValues()) {
assertThat(value.getTextContent()).isEqualTo("list");
}
// nested map
CamundaMap nestedMap = (CamundaMap) iterator.next().getUniqueChildElementByType(CamundaMap.class);
assertThat(nestedMap).isNotNull();
assertThat(nestedMap.getCamundaEntries()).hasSize(2);
Iterator<CamundaEntry> mapIterator = nestedMap.getCamundaEntries().iterator();
// nested list in nested map
CamundaEntry nestedListEntry = mapIterator.next();
assertThat(nestedListEntry).isNotNull();
assertThat(nestedListEntry.getCamundaKey()).isEqualTo("list");
CamundaList nestedNestedList = nestedListEntry.getValue();
for (BpmnModelElementInstance value : nestedNestedList.getValues()) {
assertThat(value.getTextContent()).isEqualTo("map");
}
// nested map in nested map
CamundaEntry nestedMapEntry = mapIterator.next();
assertThat(nestedMapEntry).isNotNull();
assertThat(nestedMapEntry.getCamundaKey()).isEqualTo("map");
CamundaMap nestedNestedMap = nestedMapEntry.getValue();
CamundaEntry entry = nestedNestedMap.getCamundaEntries().iterator().next();
assertThat(entry.getCamundaKey()).isEqualTo("so");
assertThat(entry.getTextContent()).isEqualTo("nested");
}
Aggregations