use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class ExtractDateTokensTest method should_update_metadata.
@Test
public void should_update_metadata() throws IOException {
// given
final List<ColumnMetadata> input = new ArrayList<>();
input.add(createMetadata("0000"));
input.add(createMetadata("0001"));
input.add(createMetadata("0002"));
final RowMetadata rowMetadata = new RowMetadata(input);
ObjectMapper mapper = new ObjectMapper();
final Statistics statistics = mapper.reader(Statistics.class).readValue(getDateTestJsonAsStream("statistics_yyyy-MM-dd.json"));
input.get(1).setStatistics(statistics);
// when
ActionTestWorkbench.test(rowMetadata, actionRegistry, factory.create(action, parameters));
// then
assertNotNull(rowMetadata.getById("0003"));
assertNotNull(rowMetadata.getById("0004"));
assertNotNull(rowMetadata.getById("0005"));
assertNotNull(rowMetadata.getById("0006"));
assertNull(rowMetadata.getById("0007"));
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class TimestampToDateTest method should_update_metadata.
@Test
public void should_update_metadata() {
// given
final List<ColumnMetadata> input = new ArrayList<>();
input.add(createMetadata("0000", "recipe"));
input.add(createMetadata("0001", "timestamp"));
input.add(createMetadata("0002", "last update"));
final RowMetadata rowMetadata = new RowMetadata(input);
final List<ColumnMetadata> expected = new ArrayList<>();
expected.add(createMetadata("0000", "recipe"));
expected.add(createMetadata("0001", "timestamp"));
expected.add(createMetadata("0003", "timestamp_as_date", Type.DATE));
expected.add(createMetadata("0002", "last update"));
// when
ActionTestWorkbench.test(rowMetadata, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expected, rowMetadata.getColumns());
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class TimestampToDateTest method should_update_metadata_twice.
@Test
public void should_update_metadata_twice() {
// given
final List<ColumnMetadata> input = new ArrayList<>();
input.add(createMetadata("0000", "recipe"));
input.add(createMetadata("0001", "timestamp"));
input.add(createMetadata("0002", "last update"));
final RowMetadata rowMetadata = new RowMetadata(input);
final List<ColumnMetadata> expected = new ArrayList<>();
expected.add(createMetadata("0000", "recipe"));
expected.add(createMetadata("0001", "timestamp"));
expected.add(createMetadata("0004", "timestamp_as_date", Type.DATE));
expected.add(createMetadata("0003", "timestamp_as_date", Type.DATE));
expected.add(createMetadata("0002", "last update"));
// when
ActionTestWorkbench.test(rowMetadata, actionRegistry, factory.create(action, parameters), factory.create(action, parameters));
// then
assertEquals(expected, rowMetadata.getColumns());
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class SplitTest method should_update_metadata.
@Test
public void should_update_metadata() {
// given
final List<ColumnMetadata> input = new ArrayList<>();
input.add(createMetadata("0000", "recipe"));
input.add(createMetadata("0001", "steps"));
input.add(createMetadata("0002", "last update"));
final RowMetadata rowMetadata = new RowMetadata(input);
final List<ColumnMetadata> expected = new ArrayList<>();
expected.add(createMetadata("0000", "recipe"));
expected.add(createMetadata("0001", "steps"));
expected.add(createMetadata("0003", "steps_split_1"));
expected.add(createMetadata("0004", "steps_split_2"));
expected.add(createMetadata("0002", "last update"));
// when
ActionTestWorkbench.test(rowMetadata, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expected, rowMetadata.getColumns());
}
use of org.talend.dataprep.api.dataset.RowMetadata in project data-prep by Talend.
the class SplitTest method test_TDP_876.
@Test
public void test_TDP_876() {
// given
final DataSetRow row = //
builder().with(//
value("lorem bacon").type(Type.STRING)).with(//
value("Bacon ipsum dolor amet swine leberkas pork belly").type(Type.STRING)).with(//
value("01/01/2015").type(Type.STRING)).build();
// when
//
ActionTestWorkbench.test(//
Collections.singletonList(row), // Test requires some analysis in asserts
analyzerService, actionRegistry, factory.create(action, parameters));
// then
final RowMetadata actual = row.getRowMetadata();
Statistics originalStats = actual.getById("0001").getStatistics();
final List<PatternFrequency> originalPatterns = originalStats.getPatternFrequencies();
assertFalse(originalPatterns.equals(actual.getById("0003").getStatistics().getPatternFrequencies()));
assertFalse(originalPatterns.equals(actual.getById("0004").getStatistics().getPatternFrequencies()));
}
Aggregations