use of org.talend.dataprep.api.dataset.statistics.Statistics in project data-prep by Talend.
the class FillWithDateIfInvalidTest method should_not_fill_non_valid_datetime.
@Test
public void should_not_fill_non_valid_datetime() throws Exception {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "David Bowie");
values.put("0001", "09/07/2015 13:31:35");
values.put("0002", "Something");
final Statistics statistics = getStatistics(this.getClass().getResourceAsStream("fillInvalidDateTimeAction_statistics.json"));
final DataSetRow row = new DataSetRow(values);
final RowMetadata rowMetadata = row.getRowMetadata();
rowMetadata.getById("0001").setType(Type.DATE.getName());
rowMetadata.getById("0001").setStatistics(statistics);
Map<String, String> parameters = ActionMetadataTestUtils.parseParameters(this.getClass().getResourceAsStream("fillInvalidDateTimeAction.json"));
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals("09/07/2015 13:31:35", row.get("0001"));
}
use of org.talend.dataprep.api.dataset.statistics.Statistics in project data-prep by Talend.
the class FillWithDateIfInvalidTest method should_fill_non_valid_datetime.
@Test
public void should_fill_non_valid_datetime() throws Exception {
// given
final Map<String, String> values = new HashMap<>();
values.put("0000", "David Bowie");
values.put("0001", "N");
values.put("0002", "Something");
final Statistics statistics = getStatistics(this.getClass().getResourceAsStream("fillInvalidDateTimeAction_statistics.json"));
final DataSetRow row = new DataSetRow(values);
row.setInvalid("0001");
final RowMetadata rowMetadata = row.getRowMetadata();
rowMetadata.getById("0001").setType(Type.DATE.getName());
rowMetadata.getById("0001").setStatistics(statistics);
Map<String, String> parameters = ActionMetadataTestUtils.parseParameters(this.getClass().getResourceAsStream("fillInvalidDateTimeAction.json"));
// when
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
// then
assertEquals("09/07/2015 13:31:36", row.get("0001"));
}
use of org.talend.dataprep.api.dataset.statistics.Statistics in project data-prep by Talend.
the class CopyColumnTest method test_TDP_567_with_force_false.
@Test
public void test_TDP_567_with_force_false() throws Exception {
List<ColumnMetadata> input = new ArrayList<>();
final ColumnMetadata original = createMetadata("0001", "column");
original.setStatistics(new Statistics());
SemanticDomain semanticDomain = new SemanticDomain("mountain_goat", "Mountain goat pale pale", 1);
original.setDomain("beer");
original.setDomainFrequency(1);
original.setDomainLabel("the best beer");
original.setDomainForced(false);
original.setTypeForced(false);
original.setSemanticDomains(Collections.singletonList(semanticDomain));
input.add(original);
RowMetadata rowMetadata = new RowMetadata(input);
assertThat(rowMetadata.getColumns()).isNotNull().isNotEmpty().hasSize(1);
final DataSetRow row = new DataSetRow(rowMetadata);
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
List<ColumnMetadata> actual = row.getRowMetadata().getColumns();
assertThat(actual).isNotNull().isNotEmpty().hasSize(2);
assertEquals(actual.get(1).getStatistics(), original.getStatistics());
//
assertThat(actual.get(1)).isEqualToComparingOnlyGivenFields(original, "domain", "domainLabel", "domainFrequency", "domainForced", "typeForced");
//
assertThat(actual.get(1).getSemanticDomains()).isNotNull().isNotEmpty().contains(semanticDomain);
}
use of org.talend.dataprep.api.dataset.statistics.Statistics in project data-prep by Talend.
the class CopyColumnTest method should_copy_statistics.
@Test
public void should_copy_statistics() throws Exception {
// given
final ColumnMetadata original = createMetadata("0001", "column");
original.setStatistics(new Statistics());
final List<ColumnMetadata> input = new ArrayList<>();
input.add(original);
final RowMetadata rowMetadata = new RowMetadata(input);
final ColumnMetadata transformed = createMetadata("0002", "column");
original.setStatistics(new Statistics());
final List<ColumnMetadata> expected = new ArrayList<>();
expected.add(createMetadata("0001", "column"));
expected.add(transformed);
// when
ActionTestWorkbench.test(rowMetadata, actionRegistry, factory.create(action, parameters));
// then
assertEquals(expected.get(1).getStatistics(), original.getStatistics());
}
use of org.talend.dataprep.api.dataset.statistics.Statistics in project data-prep by Talend.
the class CopyColumnTest method test_TDP_567_with_force_true.
@Test
public void test_TDP_567_with_force_true() throws Exception {
List<ColumnMetadata> input = new ArrayList<>();
final ColumnMetadata original = createMetadata("0001", "column");
original.setStatistics(new Statistics());
SemanticDomain semanticDomain = new SemanticDomain("mountain_goat", "Mountain goat pale pale", 1);
original.setDomain("beer");
original.setDomainFrequency(1);
original.setDomainLabel("the best beer");
original.setDomainForced(true);
original.setTypeForced(true);
original.setSemanticDomains(Collections.singletonList(semanticDomain));
input.add(original);
RowMetadata rowMetadata = new RowMetadata(input);
assertThat(rowMetadata.getColumns()).isNotNull().isNotEmpty().hasSize(1);
final DataSetRow row = new DataSetRow(rowMetadata);
ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
List<ColumnMetadata> actual = row.getRowMetadata().getColumns();
assertThat(actual).isNotNull().isNotEmpty().hasSize(2);
assertEquals(actual.get(1).getStatistics(), original.getStatistics());
//
assertThat(actual.get(1)).isEqualToComparingOnlyGivenFields(original, "domain", "domainLabel", "domainFrequency", "domainForced", "typeForced");
//
assertThat(actual.get(1).getSemanticDomains()).isNotNull().isNotEmpty().contains(semanticDomain);
}
Aggregations