use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class FormatPhoneNumberTest method testParameters.
@Test
public void testParameters() throws Exception {
final List<Parameter> parameters = action.getParameters(Locale.US);
assertEquals(7, parameters.size());
// Test on items label for TDP-2914:
final SelectParameter useWithParam = (SelectParameter) parameters.get(5);
assertEquals("Value", useWithParam.getItems().get(1).getLabel());
final SelectParameter regionsListParam = (SelectParameter) useWithParam.getItems().get(1).getParameters().get(0);
assertEquals("American standard", regionsListParam.getItems().get(0).getLabel());
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class AbstractMetadataBaseTest method forbidCreateColumn_alwaysEnabled.
private void forbidCreateColumn_alwaysEnabled() {
// 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 create a new column:
assertTrue(ActionsUtils.doesCreateNewColumn(Collections.emptyMap(), true));
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class Substring method getParameters.
@Override
public List<Parameter> getParameters(Locale locale) {
final Parameter fromIndexParameters = parameter(locale).setName(FROM_INDEX_PARAMETER).setType(INTEGER).setDefaultValue("0").build(this);
final Parameter fromNBeforeEndParameters = parameter(locale).setName(FROM_N_BEFORE_END_PARAMETER).setType(INTEGER).setDefaultValue("5").build(this);
final Parameter toIndexParameters = parameter(locale).setName(TO_INDEX_PARAMETER).setType(INTEGER).setDefaultValue("5").build(this);
final Parameter toNBeforeEndParameters = parameter(locale).setName(TO_N_BEFORE_END_PARAMETER).setType(INTEGER).setDefaultValue("1").build(this);
// "to" parameter with all possible values
final Parameter toCompleteParameters = //
selectParameter(locale).name(//
TO_MODE_PARAMETER).item(TO_END, //
TO_END).item(TO_INDEX_PARAMETER, TO_INDEX_PARAMETER, //
toIndexParameters).item(TO_N_BEFORE_END_PARAMETER, TO_N_BEFORE_END_PARAMETER, //
toNBeforeEndParameters).defaultValue(//
TO_INDEX_PARAMETER).build(this);
// "to" parameter with possible values for "From N Before End" selection
// the "to index" option should not be available
final Parameter toParametersWithoutIndexSelection = //
selectParameter(locale).name(//
TO_MODE_PARAMETER).item(TO_END, //
TO_END).item(TO_N_BEFORE_END_PARAMETER, TO_N_BEFORE_END_PARAMETER, //
toNBeforeEndParameters).defaultValue(//
TO_END).build(this);
// "from" parameter
final Parameter fromParameters = //
selectParameter(locale).name(//
FROM_MODE_PARAMETER).item(FROM_BEGINNING, FROM_BEGINNING, // has all the "To" choices
toCompleteParameters).item(FROM_INDEX_PARAMETER, FROM_INDEX_PARAMETER, fromIndexParameters, // has all the "To" choices
toCompleteParameters).item(FROM_N_BEFORE_END_PARAMETER, FROM_N_BEFORE_END_PARAMETER, fromNBeforeEndParameters, // cannot
toParametersWithoutIndexSelection).defaultValue(//
FROM_BEGINNING).build(this);
final List<Parameter> parameters = super.getParameters(locale);
parameters.add(ActionsUtils.getColumnCreationParameter(locale, CREATE_NEW_COLUMN_DEFAULT));
parameters.add(fromParameters);
return parameters;
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class AbstractMetadataBaseTest method allowCreateColumn_disabledByDefault.
private void allowCreateColumn_disabledByDefault() {
// test that 'create_new_column' parameter is present and set to 'false' 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());
assertFalse(Boolean.parseBoolean(parameter.getDefault()));
}
}
if (!found) {
fail("'Create new column' not found");
}
}
use of org.talend.dataprep.parameters.Parameter in project data-prep by Talend.
the class ConcatTest method testParameters.
@Test
public void testParameters() throws Exception {
final List<Parameter> parameters = action.getParameters(Locale.US);
assertThat(parameters.size(), is(8));
// Test on items label for TDP-2943:
final SelectParameter selectParameter = (SelectParameter) parameters.get(6);
assertEquals("Other column", selectParameter.getItems().get(0).getLabel());
assertEquals("Value", selectParameter.getItems().get(1).getLabel());
}
Aggregations