use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class PreparationAPITest method testPreparationsList_withFilterOnFolderPath.
@Test
public void testPreparationsList_withFilterOnFolderPath() throws Exception {
// given
String tagadaId = testClient.createDataset("dataset/dataset.csv", "tagada");
String preparationName = "tagadaPreparation";
String preparationId = testClient.createPreparationFromDataset(tagadaId, preparationName, home.getId());
// when : short format
final Response shouldNotBeEmpty = when().get("/api/preparations/?format=short&folder_path={folder_path}", "/");
// then
List<PreparationDTO> result = //
mapper.readerFor(//
PreparationDTO.class).<PreparationDTO>readValues(//
shouldNotBeEmpty.asInputStream()).readAll();
assertThat(result.get(0).getId(), is(preparationId));
// when
final JsonPath shouldBeEmpty = when().get("/api/preparations/?format=short&folder_path={folder_path}", "/toto").jsonPath();
// then
assertThat(shouldBeEmpty.<String>getList("id"), is(empty()));
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class PreparationService method getPreparationDetailsFull.
/**
* Return a preparation details.
*
* @param id the wanted preparation id.
* @param stepId the optional step id.
* @return the preparation details.
*/
public PreparationDetailsDTO getPreparationDetailsFull(String id, String stepId) {
final PreparationDTO prep = getPreparationDetails(id, stepId);
final PreparationDetailsDTO details = injectActionsForms(beanConversionService.convert(prep, PreparationDetailsDTO.class));
LOGGER.debug("returning details for {} -> {}", id, details);
return details;
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class ExportParametersUtil method populateFromPreparationExportParameter.
/**
* Return a copy of the export parameter with all clean value for a preparation (good step Id and good datasetId)
*
* @param exportParam incoming export param
* @return a full value copy of the export parameter
*/
public ExportParameters populateFromPreparationExportParameter(ExportParameters exportParam) throws IOException {
ExportParameters result = new ExportParameters();
result.setPreparationId(exportParam.getPreparationId());
result.setExportType(exportParam.getExportType());
result.setFrom(exportParam.getFrom());
result.setContent(exportParam.getContent());
result.setArguments(exportParam.getArguments());
result.setExportName(exportParam.getExportName());
result.setDatasetId(exportParam.getDatasetId());
result.setFilter(exportParam.getFilter());
// we deal with a preparation export parameter. We need to populate stepId and datasetId
if (StringUtils.isNotEmpty(exportParam.getPreparationId())) {
PreparationDTO prep = getPreparation(exportParam.getPreparationId(), exportParam.getStepId());
result.setStepId(getCleanStepId(prep, exportParam.getStepId()));
// for the preparation
if (exportParam.getDatasetId() == null && exportParam.getContent() == null) {
result.setDatasetId(prep.getDataSetId());
}
} else {
// it'w a dataset export parameter. We need to switch stepId to empty
result.setStepId("");
}
return result;
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class ExportAPITest method testExportCsvFromPreparationStep.
@Test
public void testExportCsvFromPreparationStep() throws Exception {
// given
final String preparationId = testClient.createPreparationFromFile("export/export_dataset.csv", "testExport", home.getId());
testClient.applyActionFromFile(preparationId, "export/upper_case_firstname.json");
testClient.applyActionFromFile(preparationId, "export/upper_case_lastname.json");
testClient.applyActionFromFile(preparationId, "export/delete_city.json");
final String expectedExport = IOUtils.toString(this.getClass().getResourceAsStream("export/expected_export_preparation_uppercase_firstname.csv"), UTF_8);
final PreparationDTO preparationMessage = mapper.readValue(given().get("/api/preparations/{preparation}/details", preparationId).asInputStream(), PreparationDTO.class);
final List<String> steps = preparationMessage.getSteps();
// when
final String export = testClient.exportPreparation(preparationId, steps.get(1)).asString();
// then
assertEquals(expectedExport, export);
}
use of org.talend.dataprep.api.preparation.PreparationDTO in project data-prep by Talend.
the class StandardExportStrategiesIntegrationTest method initPreparationDetails.
private void initPreparationDetails() throws Exception {
doReturn(preparationDetailsGet).when(applicationContext).getBean(eq(PreparationDetailsGet.class), anyString(), anyString());
final PreparationDetailsDTO preparationDetailsDTO = mapper.readerFor(//
PreparationDetailsDTO.class).readValue(this.getClass().getResourceAsStream("preparation_details.json"));
//
when(preparationDetailsGet.execute()).thenReturn(//
preparationDetailsDTO).thenReturn(preparationDetailsDTO);
doReturn(preparationSummaryGet).when(applicationContext).getBean(eq(PreparationSummaryGet.class), anyString(), anyString());
final PreparationDTO preparationDTO = mapper.readerFor(//
PreparationDTO.class).readValue(this.getClass().getResourceAsStream("preparation_details_summary.json"));
when(preparationSummaryGet.execute()).thenReturn(preparationDTO, preparationDTO);
}
Aggregations