Source:
<code>public void testDownloadCSV() throws Exception { BulkCommand command = createBuilder().param("schemas", ImmutableList.of("dublincore")) .bucket(100) .batch(40) .build(); bulkService.submit(command); assertTrue("Bulk action didn't finish", bulkService.await(command.getId(), Duration.ofSeconds(60))); BulkStatus status = bulkService.getStatus(command.getId()); assertEquals(COMPLETED, status.getState()); assertEquals(CREATED_TOTAL, status.getProcessed()); assertEquals(CREATED_TOTAL, status.getTotal()); Path dir = Files.createTempDirectory(CSVExportAction.ACTION_NAME + "test" + System.currentTimeMillis()); File testCsv = new File(dir.toFile(), "test.csv"); try (FileOutputStream out = new FileOutputStream(testCsv)) { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getMethod()).thenReturn("GET"); HttpServletResponse response = mock(HttpServletResponse.class); ServletOutputStream sos = new DummyServletOutputStream() { @Override public void write(int b) throws IOException { out.write(b); } }; PrintWriter printWriter = new PrintWriter(sos); when(response.getOutputStream()).thenReturn(sos); when(response.getWriter()).thenReturn(printWriter); String url = (String) status.getResult().get("url"); downloadService.handleDownload(request, response, null, url); } List<String> lines = Files.lines(testCsv.toPath()).collect(Collectors.toList()); int headerCount = 0; for (String line : lines) { if (line.startsWith("repository,uid")) { headerCount++; } <START> } <END> assertEquals(1, headerCount); assertEquals(CREATED_TOTAL + headerCount, lines.size()); }</code><technical_language>replaced : suggestion long count = lines.stream().filter(l -> l.startsWith("repository,uid")).count();</technical_language>

Target:
public void testDownloadCSV() throws Exception { BulkCommand command = createBuilder().param("schemas", ImmutableList.of("dublincore")) .bucket(100) .batch(40) .build(); bulkService.submit(command); assertTrue("Bulk action didn't finish", bulkService.await(command.getId(), Duration.ofSeconds(60))); BulkStatus status = bulkService.getStatus(command.getId()); assertEquals(COMPLETED, status.getState()); assertEquals(CREATED_TOTAL, status.getProcessed()); assertEquals(CREATED_TOTAL, status.getTotal()); Path dir = Files.createTempDirectory(CSVExportAction.ACTION_NAME + "test" + System.currentTimeMillis()); File testCsv = new File(dir.toFile(), "test.csv"); try (FileOutputStream out = new FileOutputStream(testCsv)) { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getMethod()).thenReturn("GET"); HttpServletResponse response = mock(HttpServletResponse.class); ServletOutputStream sos = new DummyServletOutputStream() { @Override public void write(int b) throws IOException { out.write(b); } }; PrintWriter printWriter = new PrintWriter(sos); when(response.getOutputStream()).thenReturn(sos); when(response.getWriter()).thenReturn(printWriter); String url = (String) status.getResult().get("url"); downloadService.handleDownload(request, response, null, url); } List<String> lines = Files.lines(testCsv.toPath()).collect(Collectors.toList()); long headerCount = lines.stream().filter(line -> line.startsWith("repository,uid")).count(); assertEquals(1, headerCount); assertEquals(CREATED_TOTAL + headerCount, lines.size()); }