use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.
the class OptimizedExportStrategyTest method testAcceptKO_preparationNotExist.
@Ignore
@Test(expected = TDPException.class)
public void testAcceptKO_preparationNotExist() throws Exception {
// Given
ExportParameters exportParameters = new ExportParameters();
exportParameters.setPreparationId("1234");
// Then
assertFalse(optimizedExportStrategy.accept(exportParameters));
}
use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.
the class OptimizedExportStrategyTest method testAcceptKO_noMetadataCache.
@Test
public void testAcceptKO_noMetadataCache() throws Exception {
// Given
final String preparation = createEmptyPreparationFromDataset("1234", "test");
applyAction(preparation, "[{}]");
applyAction(preparation, "[{}]");
ExportParameters exportParameters = new ExportParameters();
exportParameters.setPreparationId(preparation);
// Then
assertFalse(optimizedExportStrategy.accept(exportParameters));
}
use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.
the class OptimizedExportStrategyTest method testAcceptKO_withMetadataCacheNoContentCache.
@Test
public void testAcceptKO_withMetadataCacheNoContentCache() throws Exception {
// Given
final String preparation = createEmptyPreparationFromDataset("1234", "test");
applyAction(preparation, "[{}]");
applyAction(preparation, "[{}]");
final Preparation preparationDetails = getPreparation(preparation);
for (Step step : preparationDetails.getSteps()) {
try (OutputStream content = contentCache.put(cacheKeyGenerator.generateMetadataKey(preparation, step.id(), HEAD), ContentCache.TimeToLive.DEFAULT)) {
content.write("{}".getBytes());
content.flush();
}
}
ExportParameters exportParameters = new ExportParameters();
exportParameters.setPreparationId(preparation);
exportParameters.setFrom(HEAD);
// Then
assertFalse(optimizedExportStrategy.accept(exportParameters));
}
use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.
the class OptimizedExportStrategyTest method testExecute.
@Test
public void testExecute() throws Exception {
// Given
final String datasetId = "1234";
final String format = "JSON";
final String preparation = createEmptyPreparationFromDataset(datasetId, "test");
applyAction(preparation, "[{}]");
applyAction(preparation, "[{}]");
final Preparation preparationDetails = getPreparation(preparation);
for (Step step : preparationDetails.getSteps()) {
try (OutputStream content = contentCache.put(cacheKeyGenerator.generateMetadataKey(preparation, step.id(), HEAD), ContentCache.TimeToLive.DEFAULT)) {
content.write("{}".getBytes());
content.flush();
}
final TransformationCacheKey key = //
cacheKeyGenerator.generateContentKey(//
datasetId, //
preparation, //
step.id(), //
format, //
HEAD, // no filter
"");
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);
// Then
optimizedExportStrategy.execute(exportParameters);
}
use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.
the class PreparationExportStrategyTest method shouldUsedVersionedPreparation.
@Test
public void shouldUsedVersionedPreparation() throws IOException {
// Given
final ExportParameters parameters = new ExportParameters();
parameters.setExportType("JSON");
parameters.setPreparationId("prep-1234");
parameters.setStepId("step-1234");
final Preparation preparation = new Preparation();
preparation.setId("prep-1234");
preparation.setHeadId("step-1234");
configurePreparation(preparation, "prep-1234", "step-1234");
// When
final StreamingResponseBody body = strategy.execute(parameters);
body.writeTo(new NullOutputStream());
// Then
final ArgumentCaptor<Configuration> captor = ArgumentCaptor.forClass(Configuration.class);
verify(transformer).buildExecutable(any(), captor.capture());
assertEquals("prep-1234", captor.getValue().getPreparationId());
assertEquals("step-1234", captor.getValue().getPreparation().getHeadId());
}
Aggregations