### Question:
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { public void setCollectionInput(String collectionInput) { if (isEmpty(collectionInput)) { return; } setUpLoopCharacteristics(); String suffix = "IN_COLLECTION"; String id = Ids.dataInput(activity.getId(), suffix); DataInput dataInputElement = createDataInput(id, suffix); ioSpec.getDataInputs().add(dataInputElement); Optional<Property> property = findPropertyById(collectionInput); Optional<DataObject> dataObject = findDataObjectById(collectionInput); if (property.isPresent()) { processDataInput(dataInputElement, property.get()); } else if (dataObject.isPresent()) { processDataInput(dataInputElement, dataObject.get()); } } MultipleInstanceActivityPropertyWriter(Activity activity,
                                                  VariableScope variableScope,
                                                  Set<DataObject> dataObjects); void setCollectionInput(String collectionInput); void setCollectionOutput(String collectionOutput); void setInput(String name); void setOutput(String name); void setOutput(String name, boolean addDataOutputAssociation); void setCompletionCondition(String expression); void setIsSequential(boolean sequential);  }### Answer:
@Test public void testSetCollectionInput() { writer.setCollectionInput(PROPERTY_ID); assertInputsInitialized(); String inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX"; assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION); assertHasDataInputAssociation(activity, PROPERTY_ID, inputId); assertEquals(inputId, ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getLoopDataInputRef().getId()); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); Set<DataObject> dataObjects = new HashSet<>(); DataObject dataObject = mockDataObject(PROPERTY_ID); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionInput(PROPERTY_ID); assertInputsInitialized(); inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX"; assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION); assertHasDataInputAssociation(activity, PROPERTY_ID, inputId); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); dataObjects.clear(); dataObject = mockDataObject("SomeOtherId"); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionInput(PROPERTY_ID); assertInputsInitialized(); inputId = ACTIVITY_ID + "_" + IN_COLLECTION + "InputX"; assertHasDataInput(activity.getIoSpecification(), inputId, ITEM_ID, IN_COLLECTION); assertHasDataInputAssociation(activity, PROPERTY_ID, inputId); }