use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ComputeTimeSinceTest method testAdapt.
@Test
public void testAdapt() throws Exception {
Assert.assertThat(action.adapt((ColumnMetadata) null), is(action));
ColumnMetadata column = column().name("myColumn").id(0).type(Type.STRING).build();
Assert.assertThat(action.adapt(column), is(action));
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ComputeTimeSinceTest method should_update_metadata_twice_diff_units.
@Test
public void should_update_metadata_twice_diff_units() throws IOException {
// given
final DataSetRow row = getDefaultRow("statistics_MM_dd_yyyy.json");
final List<ColumnMetadata> expected = new ArrayList<>();
expected.add(createMetadata("0000", "recipe"));
expected.add(createMetadata("0001", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
expected.add(createMetadata("0004", "since_last update_in_days", Type.INTEGER));
expected.add(createMetadata("0003", "since_last update_in_years", Type.INTEGER));
expected.add(createMetadata("0002", "steps"));
// when
parameters.put(TIME_UNIT_PARAMETER, YEARS.name());
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
parameters.put(TIME_UNIT_PARAMETER, DAYS.name());
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expected, row.getRowMetadata().getColumns());
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class ComputeTimeSinceTest method should_update_metadata.
@Test
public void should_update_metadata() throws IOException {
// given
final DataSetRow row = getDefaultRow("statistics_MM_dd_yyyy.json");
final List<ColumnMetadata> expected = new ArrayList<>();
expected.add(createMetadata("0000", "recipe"));
expected.add(createMetadata("0001", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
expected.add(createMetadata("0003", "since_last update_in_years", Type.INTEGER));
expected.add(createMetadata("0002", "steps"));
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expected, row.getRowMetadata().getColumns());
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class DomainChangeTest method init.
@Before
public void init() {
final Map<String, String> values = new HashMap<>();
values.put("0000", "David Bowie");
values.put("0001", "");
values.put("0002", "Something");
row = new DataSetRow(values);
final RowMetadata rowMetadata = row.getRowMetadata();
ColumnMetadata columnMetadata = rowMetadata.getById("0002");
columnMetadata.setType(Type.INTEGER.getName());
columnMetadata.setDomain("FR_BEER");
columnMetadata.setDomainFrequency(1);
columnMetadata.setDomainLabel("French Beer");
parameters = new HashMap<>();
parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
parameters.put(ImplicitParameters.COLUMN_ID.getKey().toLowerCase(), "0002");
parameters.put(NEW_DOMAIN_ID_PARAMETER_KEY, "AUS_BEER");
parameters.put(NEW_DOMAIN_LABEL_PARAMETER_KEY, "Australian Beer");
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class DomainChangeTest 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.getDomain()).isEqualTo("AUS_BEER");
assertThat(column.getDomainLabel()).isEqualTo("Australian Beer");
}
Aggregations