### Question:
MultiDestinationTransferSessionImpl implements MultiDestinationTransferSession { @Override public BinaryTransferSession forDestination(StorageLocation dest) { notNull(dest, "Must provide a destination location"); BinaryTransferSession session = sessionMap.get(dest.getId()); if (session == null) { session = new BinaryTransferSessionImpl(sourceManager, dest); sessionMap.put(dest.getId(), session); } return session; } MultiDestinationTransferSessionImpl(IngestSourceManager sourceManager,
            StorageLocationManager storageLocationManager); @Override void close(); @Override BinaryTransferSession forDestination(StorageLocation dest); @Override BinaryTransferSession forObject(RepositoryObject repoObj);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void noDestination() throws Exception { try (MultiDestinationTransferSessionImpl session = new MultiDestinationTransferSessionImpl( sourceManager, storageLocationManager)) { session.forDestination(null); } }
@Test public void transfer_FSToFS_MultipleFiles_SameDestination() throws Exception { PID binPid2 = makeBinPid(); Path binDestPath2 = storagePath.resolve(binPid2.getComponentId()); when(storageLoc.getStorageUri(binPid2)).thenReturn(binDestPath2.toUri()); Path sourceFile = createSourceFile(); Path sourceFile2 = createSourceFile("another.txt", "stuff"); try (MultiDestinationTransferSessionImpl session = new MultiDestinationTransferSessionImpl( sourceManager, storageLocationManager)) { URI result1 = session.forDestination(storageLoc).transfer(binPid, sourceFile.toUri()); URI result2 = session.forDestination(storageLoc).transfer(binPid2, sourceFile2.toUri()); assertTrue(result1.toString().contains("storage/")); assertTrue(result2.toString().contains("storage/")); assertFileContent(Paths.get(result1), FILE_CONTENT); assertFileContent(Paths.get(result2), "stuff"); } }
@Test public void transfer_FSToFS_MultipleFiles_DifferentDestination() throws Exception { when(storageLoc2.getId()).thenReturn("loc2"); when(storageLoc2.getStorageType()).thenReturn(FILESYSTEM); storagePath2 = tmpFolder.newFolder("storage2").toPath(); PID binPid2 = makeBinPid(); Path binDestPath2 = storagePath2.resolve(binPid2.getComponentId()); when(storageLoc2.getStorageUri(binPid2)).thenReturn(binDestPath2.toUri()); Path sourceFile = createSourceFile(); Path sourceFile2 = createSourceFile("another.txt", "stuff"); try (MultiDestinationTransferSessionImpl session = new MultiDestinationTransferSessionImpl( sourceManager, storageLocationManager)) { URI result1 = session.forDestination(storageLoc).transfer(binPid, sourceFile.toUri()); URI result2 = session.forDestination(storageLoc2).transfer(binPid2, sourceFile2.toUri()); assertTrue(result1.toString().contains("storage/")); assertTrue(result2.toString().contains("storage2/")); assertFileContent(Paths.get(result1), FILE_CONTENT); assertFileContent(Paths.get(result2), "stuff"); } }