Search in sources :

Example 6 with Parameter

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());
}
Also used : SelectParameter(org.talend.dataprep.parameters.SelectParameter) Parameter(org.talend.dataprep.parameters.Parameter) SelectParameter(org.talend.dataprep.parameters.SelectParameter) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 7 with Parameter

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));
}
Also used : Parameter(org.talend.dataprep.parameters.Parameter)

Example 8 with Parameter

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;
}
Also used : Parameter(org.talend.dataprep.parameters.Parameter) SelectParameter.selectParameter(org.talend.dataprep.parameters.SelectParameter.selectParameter)

Example 9 with Parameter

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");
    }
}
Also used : Parameter(org.talend.dataprep.parameters.Parameter)

Example 10 with Parameter

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());
}
Also used : SelectParameter(org.talend.dataprep.parameters.SelectParameter) Parameter(org.talend.dataprep.parameters.Parameter) SelectParameter(org.talend.dataprep.parameters.SelectParameter) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Aggregations

Parameter (org.talend.dataprep.parameters.Parameter)25 Test (org.junit.Test)10 SelectParameter (org.talend.dataprep.parameters.SelectParameter)7 SelectParameter.selectParameter (org.talend.dataprep.parameters.SelectParameter.selectParameter)7 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)5 ActionDefinition (org.talend.dataprep.api.action.ActionDefinition)2 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)2 ExportFormatMessage (org.talend.dataprep.format.export.ExportFormatMessage)2 SelectParameterBuilder (org.talend.dataprep.parameters.SelectParameter.SelectParameterBuilder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 StringWriter (java.io.StringWriter)1 java.util (java.util)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)1 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)1 Action (org.talend.dataprep.api.preparation.Action)1 ParameterType (org.talend.dataprep.parameters.ParameterType)1