OptimizedExportStrategy extends BaseSampleExportStrategy { @Override public StreamingResponseBody execute(ExportParameters parameters) { final String formatName = parameters.getExportType(); final ExportFormat format = getFormat(formatName); ExportUtils.setExportHeaders(parameters.getExportName(), parameters.getArguments().get(ExportFormat.PREFIX + CSVFormat.ParametersCSV.ENCODING), format); return outputStream -> performOptimizedTransform(parameters, outputStream); }  @Override boolean test(ExportParameters parameters); @Override StreamingResponseBody execute(ExportParameters parameters);  }
@Test public void testExecute() throws Exception { final String datasetId = "1234"; final String format = "JSON"; final String preparation = createEmptyPreparationFromDataset(datasetId, "test"); applyAction(preparation, "[{}]"); applyAction(preparation, "[{}]"); final PreparationDTO preparationDetails = getPreparation(preparation); for (String step : preparationDetails.getSteps()) { try (OutputStream content = contentCache.put(cacheKeyGenerator.generateMetadataKey(preparation, step, HEAD), ContentCache.TimeToLive.DEFAULT)) { content.write("{}".getBytes()); content.flush(); } final TransformationCacheKey key = cacheKeyGenerator.generateContentKey( datasetId, preparation, step, format, HEAD, "" ); try (OutputStream content = contentCache.put(key, ContentCache.TimeToLive.DEFAULT)) { content.write("{\"records\": [{\"0000\": \"a\"}]}".getBytes()); content.flush(); } } ExportParameters exportParameters = new ExportParameters(); exportParameters.setPreparationId(preparation); exportParameters.setDatasetId(datasetId); exportParameters.setExportType(format); exportParameters.setFrom(HEAD); optimizedExportStrategy.execute(exportParameters); }