use of org.talend.dataprep.api.preparation.Preparation 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());
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class PreparationDatasetRowUpdaterTest method updatePreparations.
@Test
public void updatePreparations() throws Exception {
// given
String datasetId = "dataset id";
Preparation prep = new Preparation("prepId", "123456");
prep.setDataSetId(datasetId);
final List<Preparation> preparations = singletonList(prep);
when(preparationRepository.list(Preparation.class)).thenReturn(preparations.stream());
DataSetMetadata datasetMetadata = new DataSetMetadata();
datasetMetadata.setRowMetadata(new RowMetadata());
when(dataSetMetadataRepository.get(datasetId)).thenReturn(datasetMetadata);
// when
updater.updatePreparations();
// then
verify(preparationRepository, times(1)).list(Preparation.class);
verify(preparationRepository, times(1)).add(prep);
verify(dataSetMetadataRepository, only()).get(datasetId);
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class PreparationExportStrategyTest method shouldUsedHeadPreparation.
@Test
public void shouldUsedHeadPreparation() throws IOException {
// Given
final ExportParameters parameters = new ExportParameters();
parameters.setExportType("JSON");
parameters.setPreparationId("prep-1234");
parameters.setStepId("head");
final Preparation preparation = new Preparation();
preparation.setId("prep-1234");
preparation.setHeadId("head");
configurePreparation(preparation, "prep-1234", "head");
// 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("head", captor.getValue().getPreparation().getHeadId());
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class AddAllPreparationsToHomeTest method shouldAddAllPreparationsToHome.
@Test
public void shouldAddAllPreparationsToHome() throws Exception {
// given
final String homeFolderId = folderRepository.getHome().getId();
// when
task.run();
// then
final Stream<Preparation> preparations = preparationRepository.list(Preparation.class);
preparations.forEach(p -> {
final Folder folder = folderRepository.locateEntry(p.getId(), PREPARATION);
assertEquals(homeFolderId, folder.getId());
});
}
use of org.talend.dataprep.api.preparation.Preparation in project data-prep by Talend.
the class PrepHasStepCondition method apply.
@Override
public boolean apply(Object... args) {
// check pre-condition
Validate.notNull(args);
Validate.isTrue(args.length == 2);
Validate.isInstanceOf(String.class, args[0]);
Validate.isInstanceOf(String.class, args[1]);
String preparationId = (String) args[0];
String headId = (String) args[1];
Preparation prep = exportParametersUtil.getPreparation(preparationId, headId);
return prep.getSteps().size() > 1;
}
Aggregations