use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class RoundCeilTest method test_apply_in_newcolumn.
@Test
public void test_apply_in_newcolumn() {
// given
final Map<String, String> values = new LinkedHashMap<>();
values.put("0000", "-5.1");
values.put("0001", "3.0");
values.put("0002", "Done !");
final DataSetRow row = new DataSetRow(values);
final Map<String, Object> expectedValues = new HashMap<>();
expectedValues.put("0000", "-5.1");
expectedValues.put("0001", "3.0");
expectedValues.put("0002", "Done !");
expectedValues.put("0003", "-5");
parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("0000_rounded").type(Type.DOUBLE).build();
ColumnMetadata actual = row.getRowMetadata().getById("0003");
assertEquals(expected, actual);
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class RoundDownTest 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 RoundDownTest method test_apply_in_newcolumn.
@Test
public void test_apply_in_newcolumn() {
// given
final Map<String, String> values = new LinkedHashMap<>();
values.put("0000", "-5.1");
values.put("0001", "3.0");
values.put("0002", "Done !");
final DataSetRow row = new DataSetRow(values);
final Map<String, Object> expectedValues = new HashMap<>();
expectedValues.put("0000", "-5.1");
expectedValues.put("0001", "3.0");
expectedValues.put("0002", "Done !");
expectedValues.put("0003", "-5");
parameters.put(ActionsUtils.CREATE_NEW_COLUMN, "true");
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expectedValues, row.values());
ColumnMetadata expected = ColumnMetadata.Builder.column().id(3).name("0000_rounded").type(Type.DOUBLE).build();
ColumnMetadata actual = row.getRowMetadata().getById("0003");
assertEquals(expected, actual);
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class RoundFloorTest 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 RoundHalfUpTest 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));
}
Aggregations