Source:
<code>public void downloadZipComplex() throws IOException { final ApiClient ownerWebClient = getWebClient(USER_2_USERNAME, testingPostgres); WorkflowsApi ownerWorkflowApi = new WorkflowsApi(ownerWebClient); Workflow refresh = registerGatkSvWorkflow(ownerWorkflowApi); Long workflowId = refresh.getId(); Long versionId = refresh.getWorkflowVersions().get(0).getId(); ownerWorkflowApi.getWorkflowZip(workflowId, versionId); final io.dockstore.webservice.core.Workflow dockstoreWorkflow = workflowDAO.findById(workflowId); final Optional<io.dockstore.webservice.core.WorkflowVersion> version = dockstoreWorkflow.getWorkflowVersions().stream() .filter(wv -> wv.getId() == versionId).findFirst(); Assert.assertTrue(version.isPresent()); final File tempFile = File.createTempFile("dockstore-test", ".zip"); try { <START> final FileOutputStream fos = new FileOutputStream(tempFile); <END> final Set<io.dockstore.webservice.core.SourceFile> sourceFiles = version.get().getSourceFiles(); new EntryVersionHelperImpl().writeStreamAsZip(sourceFiles, fos, Paths.get("/GATKSVPipelineClinical.wdl")); final ZipFile zipFile = new ZipFile(tempFile); final long wdlCount = zipFile.stream().filter(e -> e.getName().endsWith(".wdl")).count(); Assert.assertEquals(sourceFiles.size(), wdlCount); zipFile.stream().filter(e -> e.getName().endsWith(".wdl")).forEach(e -> { final String name = "/" + e.getName(); Assert.assertTrue("expected " + name, sourceFiles.stream().anyMatch(sf -> sf.getAbsolutePath().equals(name))); }); zipFile.close(); } finally { FileUtils.deleteQuietly(tempFile); } }</code><technical_language>fos need closed? If so, move try</technical_language>

Target:
public void downloadZipComplex() throws IOException { final ApiClient ownerWebClient = getWebClient(USER_2_USERNAME, testingPostgres); WorkflowsApi ownerWorkflowApi = new WorkflowsApi(ownerWebClient); Workflow refresh = registerGatkSvWorkflow(ownerWorkflowApi); Long workflowId = refresh.getId(); Long versionId = refresh.getWorkflowVersions().get(0).getId(); ownerWorkflowApi.getWorkflowZip(workflowId, versionId); final io.dockstore.webservice.core.Workflow dockstoreWorkflow = workflowDAO.findById(workflowId); final Optional<io.dockstore.webservice.core.WorkflowVersion> version = dockstoreWorkflow.getWorkflowVersions().stream() .filter(wv -> wv.getId() == versionId).findFirst(); Assert.assertTrue(version.isPresent()); final File tempFile = File.createTempFile("dockstore-test", ".zip"); try (FileOutputStream fos = new FileOutputStream(tempFile)) { final Set<io.dockstore.webservice.core.SourceFile> sourceFiles = version.get().getSourceFiles(); new EntryVersionHelperImpl().writeStreamAsZip(sourceFiles, fos, Paths.get("/GATKSVPipelineClinical.wdl")); final ZipFile zipFile = new ZipFile(tempFile); final long wdlCount = zipFile.stream().filter(e -> e.getName().endsWith(".wdl")).count(); Assert.assertEquals(sourceFiles.size(), wdlCount); zipFile.stream().filter(e -> e.getName().endsWith(".wdl")).forEach(e -> { final String name = "/" + e.getName(); Assert.assertTrue("expected " + name, sourceFiles.stream().anyMatch(sf -> sf.getAbsolutePath().equals(name))); }); zipFile.close(); } finally { FileUtils.deleteQuietly(tempFile); } }