### Question:
TarCollectionMicroservice extends Microservice { @Override public ExecResult execute(final TransferStatus transferStatus) throws MicroserviceException { log.info("execute"); String tarFileName = (String) getInvocationContext() .getSharedProperties().get(TAR_FILE_NAME); if (tarFileName == null) { File sourceFile = new File( transferStatus.getSourceFileAbsolutePath()); log.info("no tar file, create a temp dir for this tar file"); StringBuilder targetDir = new StringBuilder(); targetDir.append(sourceFile.getParent()); targetDir.append("/contents"); targetDir.append(System.currentTimeMillis()); targetDir.append(".tar"); tarFileName = targetDir.toString(); } log.info("tar file name will be:{}", tarFileName); LocalTarFileArchiver localFileTarArchiver = new LocalTarFileArchiver( transferStatus.getSourceFileAbsolutePath(), tarFileName); try { File archiveFile = localFileTarArchiver.createArchive(); getInvocationContext().getSharedProperties().put( EnqueueTransferMicroservice.LOCAL_FILE_NAME, archiveFile.getAbsolutePath()); return ExecResult.CONTINUE; } catch (FileNotFoundException e) { log.error("fileNotFoundException on create of tar file", e); throw new MicroserviceException( "microservice exception creating tar file", e); } catch (JargonException e) { log.error("JargonException on create of tar file", e); throw new MicroserviceException( "JargonException creating tar file", e); } }  @Override ExecResult execute(final TransferStatus transferStatus); static final String TAR_FILE_NAME; }### Answer:
@Test public void testUntarCollectionInIRODS() throws Exception { String host = "test"; String zone = "zone"; Transfer transfer = new Transfer(); GridAccount gridAccount = new GridAccount(); gridAccount.setHost(host); gridAccount.setZone(zone); transfer.setTransferType(TransferType.PUT); transfer.setGridAccount(gridAccount); TransferAttempt transferAttempt = new TransferAttempt(); transferAttempt.setTransfer(transfer); DefaultTransferControlBlock.instance(); String rootCollection = "testUntarCollectionInIRODS"; String localCollectionAbsolutePath = scratchFileUtils .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH + '/' + rootCollection); TransferStatus transferStatus = TransferStatus.instance( TransferStatus.TransferType.PUT, localCollectionAbsolutePath, "blah", "", 0, 0, 0, 0, 0, TransferState.OVERALL_INITIATION, "host", "zone"); String tarParentCollection = scratchFileUtils .createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH); File tarFile = new File(tarParentCollection); tarFile = new File(tarFile.getParentFile(), "contents.tar"); FileGenerator .generateManyFilesAndCollectionsInParentCollectionByAbsolutePath( localCollectionAbsolutePath, rootCollection, 2, 3, 2, "testFile", ".txt", 3, 2, 1, 200 * 1024); Microservice tarCollectionMicroservice = new TarCollectionMicroservice(); InvocationContext invocationContext = new InvocationContext(); ContainerEnvironment containerEnvironment = new ContainerEnvironment(); tarCollectionMicroservice.setInvocationContext(invocationContext); tarCollectionMicroservice.setContainerEnvironment(containerEnvironment); ExecResult result = tarCollectionMicroservice.execute(transferStatus); Assert.assertEquals("should get continue as exec result", ExecResult.CONTINUE, result); String sourcePath = (String) invocationContext.getSharedProperties() .get(EnqueueTransferMicroservice.LOCAL_FILE_NAME); Assert.assertNotNull("no source path put in shared context", sourcePath); }