### Question:
MultipleInstanceActivityPropertyWriter extends ActivityPropertyWriter { public void setCollectionOutput(String collectionOutput) { if (isEmpty(collectionOutput)) { return; } setUpLoopCharacteristics(); String suffix = "OUT_COLLECTION"; String id = Ids.dataOutput(activity.getId(), suffix); DataOutput dataOutputElement = createDataOutput(id, suffix); addSafe(ioSpec.getDataOutputs(), dataOutputElement); Optional<Property> property = findPropertyById(collectionOutput); Optional<DataObject> dataObject = findDataObjectById(collectionOutput); if (property.isPresent()) { processDataOutput(dataOutputElement, property.get()); } else if (dataObject.isPresent()) { processDataOutput(dataOutputElement, 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 testSetCollectionOutput() { writer.setCollectionOutput(PROPERTY_ID); assertOutputsInitialized(); String outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX"; assertHasDataOutput(activity.getIoSpecification(), outputId, ITEM_ID, OUT_COLLECTION); assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID); assertEquals(outputId, ((MultiInstanceLoopCharacteristics) activity.getLoopCharacteristics()).getLoopDataOutputRef().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.setCollectionOutput(PROPERTY_ID); assertOutputsInitialized(); outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX"; assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID); when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.empty()); dataObjects.clear(); dataObject = mockDataObject("SomeOtherId"); dataObjects.add(dataObject); writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, dataObjects); writer.setCollectionOutput(PROPERTY_ID); assertOutputsInitialized(); outputId = ACTIVITY_ID + "_" + OUT_COLLECTION + "OutputX"; assertHasDataOutputAssociation(activity, outputId, PROPERTY_ID); }