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;
}
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());
}
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());
}
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());
}
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());
}
Aggregations