use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ExtractUrlTokensTest method should_accept_column.
@Test
public void should_accept_column() {
ColumnMetadata column = getColumn(Type.STRING);
column.setDomain("url");
assertTrue(action.acceptField(column));
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ExtractUrlTokensTest method should_not_accept_column.
@Test
public void should_not_accept_column() {
assertFalse(action.acceptField(getColumn(Type.STRING)));
assertFalse(action.acceptField(getColumn(Type.DATE)));
assertFalse(action.acceptField(getColumn(Type.BOOLEAN)));
assertFalse(action.acceptField(getColumn(Type.NUMERIC)));
assertFalse(action.acceptField(getColumn(Type.INTEGER)));
assertFalse(action.acceptField(getColumn(Type.DOUBLE)));
assertFalse(action.acceptField(getColumn(Type.FLOAT)));
ColumnMetadata column = getColumn(Type.STRING);
column.setDomain("not an url");
assertFalse(action.acceptField(column));
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ExtractUrlTokensTest method testAdapt.
@Test
public void testAdapt() throws Exception {
assertThat(action.adapt((ColumnMetadata) null), is(action));
ColumnMetadata column = column().name("myColumn").id(0).type(Type.STRING).build();
assertThat(action.adapt(column), is(action));
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class FormatPhoneNumberTest method test_apply_in_newcolumn.
@Test
public void test_apply_in_newcolumn() {
// given
parameters.put(FormatPhoneNumber.REGIONS_PARAMETER_CONSTANT_MODE, "FR");
parameters.put(FormatPhoneNumber.FORMAT_TYPE_PARAMETER, FormatPhoneNumber.TYPE_INTERNATIONAL);
parameters.put(OtherColumnParameters.MODE_PARAMETER, OtherColumnParameters.CONSTANT_MODE);
parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
Map<String, String> values = new HashMap<>();
values.put("0000", "+33656965822");
DataSetRow row = new DataSetRow(values);
Map<String, Object> expectedValues = new LinkedHashMap<>();
expectedValues.put("0000", "+33656965822");
expectedValues.put("0001", "+33 6 56 96 58 22");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
ColumnMetadata expected = ColumnMetadata.Builder.column().id(1).name("0000_formatted").type(Type.STRING).build();
ColumnMetadata actual = row.getRowMetadata().getById("0001");
assertEquals(expected, actual);
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ContainsTest method should_set_new_column_name_column_mode.
@Test
public void should_set_new_column_name_column_mode() {
// given
final DataSetRow row = //
builder().with(//
value("first").type(Type.STRING).name("source")).with(//
value("second").type(Type.STRING).name("name")).with(//
value("Done !").type(Type.STRING)).build();
parameters.put(Contains.MODE_PARAMETER, Contains.OTHER_COLUMN_MODE);
parameters.put(Contains.SELECTED_COLUMN_PARAMETER, "0000");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("name_contains_source").type(Type.BOOLEAN).build();
ColumnMetadata actual = row.getRowMetadata().getById("0003");
assertEquals(expected, actual);
}
Aggregations