Search in sources :

Example 1 with SelectParameter

use of org.talend.dataprep.parameters.SelectParameter in project data-prep by Talend.

the class AbstractDate method getParametersForDatePattern.

/**
 * @return the Parameters to display for the date related action.
 */
protected List<Parameter> getParametersForDatePattern(Locale locale) {
    HashMap<String, String> datePatterns = loadDatePatterns();
    SelectParameter.SelectParameterBuilder selectParamBuilder = SelectParameter.selectParameter(locale).name(NEW_PATTERN);
    String defaultItem = null;
    for (Map.Entry<String, String> datePatternEntry : datePatterns.entrySet()) {
        String key = datePatternEntry.getKey();
        String value = datePatternEntry.getValue();
        selectParamBuilder.constant(value, choice(this, locale, key));
        if ("ISO".equals(key)) {
            defaultItem = value;
        }
        if (defaultItem == null) {
            defaultItem = value;
        }
    }
    SelectParameter custom = // 
    selectParamBuilder.item("custom", "custom", // 
    buildCustomPatternParam(locale)).defaultValue(// 
    defaultItem).build(this);
    custom.getItems().sort(compareOnLabelWithCustomLast());
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(custom);
    return parameters;
}
Also used : SelectParameter(org.talend.dataprep.parameters.SelectParameter) Parameter(org.talend.dataprep.parameters.Parameter) SelectParameter(org.talend.dataprep.parameters.SelectParameter)

Example 2 with SelectParameter

use of org.talend.dataprep.parameters.SelectParameter in project data-prep by Talend.

the class ComputeTimeSinceTest method testParameters.

@Test
public void testParameters() throws Exception {
    final List<Parameter> parameters = action.getParameters(Locale.US);
    Assert.assertThat(parameters.size(), is(7));
    // Test on items label for TDP-2943:
    final SelectParameter selectParameter = (SelectParameter) parameters.get(6);
    assertEquals("Now", selectParameter.getItems().get(0).getLabel());
    assertEquals("Specific date", selectParameter.getItems().get(1).getLabel());
    assertEquals("Other column", selectParameter.getItems().get(2).getLabel());
}
Also used : SelectParameter(org.talend.dataprep.parameters.SelectParameter) Parameter(org.talend.dataprep.parameters.Parameter) SelectParameter(org.talend.dataprep.parameters.SelectParameter) Test(org.junit.Test)

Example 3 with SelectParameter

use of org.talend.dataprep.parameters.SelectParameter 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 4 with SelectParameter

use of org.talend.dataprep.parameters.SelectParameter in project data-prep by Talend.

the class ChangeDatePatternTest method testParameters.

@Test
public void testParameters() throws Exception {
    // 4 predefined patterns + custom = 6
    assertThat(action.getParameters(Locale.US).size(), is(7));
    // Test on items label for TDP-2944:
    final SelectParameter newFormatParam = (SelectParameter) action.getParameters(Locale.US).get(6);
    assertEquals("American standard", newFormatParam.getItems().get(0).getLabel());
}
Also used : SelectParameter(org.talend.dataprep.parameters.SelectParameter) Test(org.junit.Test)

Example 5 with SelectParameter

use of org.talend.dataprep.parameters.SelectParameter 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

SelectParameter (org.talend.dataprep.parameters.SelectParameter)9 Test (org.junit.Test)7 Parameter (org.talend.dataprep.parameters.Parameter)5 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)3 StringWriter (java.io.StringWriter)1 Item (org.talend.dataprep.parameters.Item)1