use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ReorderColumnTest 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 TypeChangeTest method test_apply_inplace.
@Test
public void test_apply_inplace() throws Exception {
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final ColumnMetadata column = row.getRowMetadata().getById("0002");
assertThat(column.getType()).isEqualTo("string");
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class TypeChangeTest method should_not_accept_any_type_to_avoid_transformation_to_be_in_transfo_list.
@Test
public void should_not_accept_any_type_to_avoid_transformation_to_be_in_transfo_list() {
// given
final DomainChange domainChange = new DomainChange();
for (final Type type : Type.values()) {
final ColumnMetadata columnMetadata = //
ColumnMetadata.Builder.column().type(//
type).computedId(//
"0002").domain(//
"FR_BEER").domainFrequency(//
1).domainLabel(//
"French Beer").build();
// when
final boolean accepted = domainChange.acceptField(columnMetadata);
// then
assertThat(accepted).isTrue();
}
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class TypeChangeTest method should_reset_domain.
@Test
public void should_reset_domain() throws Exception {
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
final ColumnMetadata column = row.getRowMetadata().getById("0002");
assertThat(column.getDomain()).isEqualTo("");
assertThat(column.getDomainLabel()).isEqualTo("");
assertThat(column.getDomainFrequency()).isEqualTo(0);
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class DistanceConverterTest method test_apply_in_newcolumn.
@Test
public void test_apply_in_newcolumn() {
// given
Map<String, String> rowContent = new HashMap<>();
rowContent.put("0000", "David");
rowContent.put("0001", "1.0");
final DataSetRow row1 = new DataSetRow(rowContent);
row1.setTdpId(123L);
final Map<String, String> parameters = new HashMap<>();
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put("column_id", "0001");
parameters.put("from_unit", DistanceEnum.KILOMETER.name());
parameters.put("to_unit", DistanceEnum.MILE.name());
parameters.put("precision", "9");
parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
// when
ActionTestWorkbench.test(Collections.singletonList(row1), actionRegistry, factory.create(action, parameters));
// then
assertEquals("1.0", row1.get("0001"));
assertEquals("0.621371192", row1.get("0002"));
ColumnMetadata expected = ColumnMetadata.Builder.column().id(2).name("0001_in_MILE").type(Type.DOUBLE).build();
ColumnMetadata actual = row1.getRowMetadata().getById("0002");
assertEquals(expected, actual);
}
Aggregations