use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class DateParserTest method shouldNotComputePatternFromDQBecauseEmptyValue.
@Test(expected = DateTimeException.class)
public void shouldNotComputePatternFromDQBecauseEmptyValue() {
final ColumnMetadata column = ActionMetadataTestUtils.getColumn(Type.DATE);
action.guessPattern("", column);
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class DateParserTest method shouldComputePatternFromDQ.
@Test
public void shouldComputePatternFromDQ() {
final ColumnMetadata column = ActionMetadataTestUtils.getColumn(Type.DATE);
assertEquals(new DatePattern("dd/MM/yyyy", 1), action.guessPattern("01/02/2015", column));
assertEquals(new DatePattern("d/M/yyyy", 1), action.guessPattern("1/2/2015", column));
assertEquals(new DatePattern("yyyy-MM-dd", 1), action.guessPattern("2015-01-02", column));
assertEquals(new DatePattern("9999", 1), action.guessPattern("2015", column));
assertEquals(new DatePattern("MMMM d yyyy", 1), action.guessPattern("July 14 2015", column));
}
use of org.talend.dataprep.api.dataset.ColumnMetadata in project data-prep by Talend.
the class DateParserTest method shouldUpdateColumnStatisticsWithNewDatePattern.
@Test
public void shouldUpdateColumnStatisticsWithNewDatePattern() {
// given
ColumnMetadata column = ActionMetadataTestUtils.getColumn(Type.DATE);
column.getStatistics().getPatternFrequencies().add(new PatternFrequency("yyyy", 19));
// when
action.guessAndParse("01/02/2015", column);
// then
final List<PatternFrequency> actual = column.getStatistics().getPatternFrequencies();
assertEquals(2, actual.size());
assertEquals(new PatternFrequency("dd/MM/yyyy", 1), actual.get(1));
}
use of org.talend.dataprep.api.dataset.ColumnMetadata 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.ColumnMetadata in project data-prep by Talend.
the class ExtractDateTokensTest 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