use of org.talend.dataprep.format.export.ExportFormatMessage in project data-prep by Talend.
the class BaseFormatTest method testFormat.
protected void testFormat(ExportFormat format, String expectedJson) throws IOException {
StringWriter writer = new StringWriter();
final ExportFormatMessage exportFormatMessage = beanConversionService.convert(format, ExportFormatMessage.class);
mapper.writer().writeValue(writer, exportFormatMessage);
assertThat(writer.toString(), sameJSONAsFile(BaseFormatTest.class.getResourceAsStream(expectedJson)));
}
use of org.talend.dataprep.format.export.ExportFormatMessage in project data-prep by Talend.
the class CSVFormatTest method csv.
@Test
public void csv() {
// when
final ExportFormatMessage exportFormatMessage = beanConversionService.convert(format, ExportFormatMessage.class);
// then
assertEquals("text/csv", exportFormatMessage.getMimeType());
assertEquals("CSV", exportFormatMessage.getId());
assertEquals("Local CSV file", exportFormatMessage.getName());
assertEquals(true, exportFormatMessage.isNeedParameters());
assertEquals(false, exportFormatMessage.isDefaultExport());
assertEquals(true, exportFormatMessage.isEnabled());
assertEquals("", exportFormatMessage.getDisableReason());
assertEquals("Export to CSV", exportFormatMessage.getTitle());
List<Parameter> parameters = exportFormatMessage.getParameters();
assertNotNull(parameters);
assertEquals(6, parameters.size());
}
use of org.talend.dataprep.format.export.ExportFormatMessage in project data-prep by Talend.
the class ExportFormatConversions method doWith.
@Override
public BeanConversionService doWith(BeanConversionService conversionService, String beanName, ApplicationContext applicationContext) {
final MessagesBundle messagesBundle = applicationContext.getBean(MessagesBundle.class);
conversionService.register(//
fromBean(ExportFormat.class).toBeans(//
ExportFormatMessage.class).using(ExportFormatMessage.class, (exportFormat, exportFormatMessage) -> {
final String code = "export." + exportFormat.getName() + ".display";
final String displayName = messagesBundle.getString(LocaleContextHolder.getLocale(), code);
exportFormatMessage.setId(exportFormat.getName());
exportFormatMessage.setName(displayName);
exportFormatMessage.setSupportSampling(exportFormat.supportSampling());
return exportFormatMessage;
}).build());
return conversionService;
}
use of org.talend.dataprep.format.export.ExportFormatMessage in project data-prep by Talend.
the class ExportAPITest method get_all_export_types.
@Test
public void get_all_export_types() throws Exception {
// given
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// when
String actualJsonString = RestAssured.when().get("/api/export/formats").asString();
List<ExportFormatMessage> exportFormatMessageList = mapper.readValue(actualJsonString, new TypeReference<List<ExportFormatMessage>>() {
});
ExportFormatMessage exportFormatMessageCSV = exportFormatMessageList.get(0);
ExportFormatMessage exportFormatMessageXLSX = exportFormatMessageList.get(1);
// then
assertEquals("text/csv", exportFormatMessageCSV.getMimeType());
assertEquals("CSV", exportFormatMessageCSV.getId());
assertEquals("Local CSV file", exportFormatMessageCSV.getName());
assertEquals(true, exportFormatMessageCSV.isNeedParameters());
assertEquals(false, exportFormatMessageCSV.isDefaultExport());
assertEquals(true, exportFormatMessageCSV.isEnabled());
assertEquals(true, exportFormatMessageCSV.isSupportSampling());
assertEquals("", exportFormatMessageCSV.getDisableReason());
assertEquals("Export to CSV", exportFormatMessageCSV.getTitle());
List<Parameter> parametersCSV = exportFormatMessageCSV.getParameters();
assertNotNull(parametersCSV);
assertEquals(6, parametersCSV.size());
// Andthen
assertEquals("application/vnd.ms-excel", exportFormatMessageXLSX.getMimeType());
assertEquals("XLSX", exportFormatMessageXLSX.getId());
assertEquals("Local XLSX file", exportFormatMessageXLSX.getName());
assertEquals(true, exportFormatMessageXLSX.isNeedParameters());
assertEquals(true, exportFormatMessageXLSX.isDefaultExport());
assertEquals(true, exportFormatMessageXLSX.isEnabled());
assertEquals(true, exportFormatMessageXLSX.isSupportSampling());
assertEquals("", exportFormatMessageXLSX.getDisableReason());
assertEquals("Export to XLSX", exportFormatMessageXLSX.getTitle());
List<Parameter> parametersXLS = exportFormatMessageXLSX.getParameters();
assertNotNull(parametersXLS);
assertEquals(1, parametersXLS.size());
}
use of org.talend.dataprep.format.export.ExportFormatMessage in project data-prep by Talend.
the class ExportPreparationStep method whenIGetExportFormat.
@When("^I get the export formats for the preparation \"(.*)\"$")
public void whenIGetExportFormat(String preparationName) throws IOException {
String preparationId = context.getPreparationId(suffixName(preparationName));
Response apiResponse = api.getExportFormats(preparationId);
ExportFormatMessage[] parameters = objectMapper.readValue(apiResponse.getBody().asString(), ExportFormatMessage[].class);
context.storePreparationExportFormat(suffixName(preparationName), parameters);
}
Aggregations