use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class ParameterTest method shouldSerializeToJsonWithoutEmptyConfiguration.
@Test
public void shouldSerializeToJsonWithoutEmptyConfiguration() throws IOException {
// given
Parameter expected = Parameter.parameter(Locale.US).setName("column_id").setType(ParameterType.STRING).setDefaultValue("0001").setImplicit(true).setCanBeBlank(false).setReadonly(true).build(this);
// when
StringWriter out = new StringWriter();
mapper.writer().writeValue(out, expected);
// then
assertThat(out.toString(), sameJSONAs(IOUtils.toString(this.getClass().getResourceAsStream("textParameter.json"), UTF_8)));
}
use of org.talend.dataprep.parameters.Parameter 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.parameters.Parameter in project data-prep by Talend.
the class RenameTest method testAdapt.
@Test
public void testAdapt() throws Exception {
assertThat(action.adapt((ColumnMetadata) null), is(action));
ColumnMetadata column = column().name("myColumn").id(0).type(Type.STRING).build();
assertThat(action.adapt(column), not(is(action)));
boolean hasMetExpectedParameter = false;
for (Parameter parameter : action.adapt(column).getParameters(Locale.US)) {
if (Rename.NEW_COLUMN_NAME_PARAMETER_NAME.equals(parameter.getName())) {
assertThat(parameter.getDefault(), is(column.getName()));
hasMetExpectedParameter = true;
}
}
assertThat(hasMetExpectedParameter, is(true));
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class AbstractMetadataBaseTest method forbidCreateColumn_alwaysDisabled.
private void forbidCreateColumn_alwaysDisabled() {
// test that 'create_new_column' parameter is not present:
final List<Parameter> parameters = action.getParameters(Locale.getDefault());
for (Parameter parameter : parameters) {
if (parameter.getName().equals(CREATE_NEW_COLUMN)) {
fail("'Create new column' found, while it should not");
}
}
// test that this action will not create a new column:
assertFalse(ActionsUtils.doesCreateNewColumn(Collections.<String, String>emptyMap(), false));
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class AbstractMetadataBaseTest method allowCreateColumn_enabledByDefault.
private void allowCreateColumn_enabledByDefault() {
// test that 'create_new_column' parameter is present and set to 'true' by default:
final List<Parameter> parameters = action.getParameters(Locale.getDefault());
boolean found = false;
for (Parameter parameter : parameters) {
if (parameter.getName().equals(CREATE_NEW_COLUMN)) {
found = true;
assertEquals("Create new column", parameter.getLabel());
assertTrue(Boolean.parseBoolean(parameter.getDefault()));
}
}
if (!found) {
fail("'Create new column' not found");
}
}
Aggregations