use of org.talend.dataprep.parameters.SelectParameter in project data-prep by Talend.
the class SelectParameterTest method shouldCreateConstantItem.
@Test
public void shouldCreateConstantItem() {
// when
final SelectParameter params = SelectParameter.selectParameter(Locale.US).constant("key", "a constant key").build(this);
// then
assertThat(params.getItems().get(0).getValue(), is("key"));
assertThat(params.getItems().get(0).getLabel(), is("a constant key"));
}
use of org.talend.dataprep.parameters.SelectParameter in project data-prep by Talend.
the class TestI18nKeysForActionsTest method assertParameter.
private void assertParameter(Parameter param) {
String parameterName = param.getName();
assertNotNull(parameterName);
assertNotEquals("", parameterName);
String parameterLabel = param.getLabel();
assertNotNull(parameterLabel);
assertNotEquals("", parameterLabel);
String parameterDescription = param.getDescription();
assertNotNull(parameterDescription);
assertNotEquals("", parameterDescription);
LOGGER.trace(" - " + parameterName + " | " + parameterLabel + " | " + parameterDescription);
if (param instanceof SelectParameter) {
List<Item> values = ((SelectParameter) param).getItems();
for (Item value : values) {
assertItem(value);
}
}
}
use of org.talend.dataprep.parameters.SelectParameter in project data-prep by Talend.
the class SelectParameterTest method shouldSerializeToJsonWithItemsInConfiguration.
@Test
public void shouldSerializeToJsonWithItemsInConfiguration() throws IOException {
// given
SelectParameter expected = SelectParameter.selectParameter(//
Locale.US).name(//
"column_id").defaultValue(//
"").implicit(//
false).canBeBlank(//
false).item(//
"first value").item(//
"2").item("your choice", Parameter.parameter(Locale.US).setName("limit").setType(ParameterType.INTEGER).setDefaultValue(StringUtils.EMPTY).setCanBeBlank(false).build(//
this)).build(this);
// when
StringWriter out = new StringWriter();
mapper.writer().writeValue(out, expected);
// then
assertThat(out.toString(), sameJSONAs(IOUtils.toString(this.getClass().getResourceAsStream("selectParameter.json"), UTF_8)));
}
use of org.talend.dataprep.parameters.SelectParameter in project data-prep by Talend.
the class RemoveRepeatedCharsTest method testGetParameters.
@Test
public void testGetParameters() throws Exception {
final List<Parameter> parameters = action.getParameters(Locale.US);
assertEquals(6, parameters.size());
final SelectParameter parameter4 = (SelectParameter) parameters.get(5);
assertEquals(2, parameter4.getItems().size());
assertEquals("Whitespace", parameter4.getItems().get(0).getLabel());
assertEquals("Other", parameter4.getItems().get(1).getLabel());
}
Aggregations