Search in sources :

Example 1 with DeleteInvalid

use of org.talend.dataprep.transformation.actions.delete.DeleteInvalid in project data-prep by Talend.

the class SimpleSuggestionEngineTest method shouldSuggestionsShouldBeSorted.

@Test
public void shouldSuggestionsShouldBeSorted() throws IOException {
    final String json = IOUtils.toString(this.getClass().getResourceAsStream("sample_column.json"), UTF_8);
    ObjectMapper mapper = new ObjectMapper();
    final ColumnMetadata columnMetadata = mapper.readValue(json, ColumnMetadata.class);
    List<ActionDefinition> actions = new ArrayList<>();
    actions.add(new FillIfEmpty());
    actions.add(new FillInvalid());
    actions.add(new DeleteInvalid());
    actions.add(new DeleteEmpty());
    actions.add(new Absolute());
    actions.add(new UpperCase());
    final Stream<Suggestion> suggestions = engine.score(actions.stream(), columnMetadata);
    int currentScore = Integer.MAX_VALUE;
    for (Suggestion suggestion : suggestions.collect(Collectors.toList())) {
        assertTrue(currentScore >= suggestion.getScore());
        currentScore = suggestion.getScore();
    }
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) UpperCase(org.talend.dataprep.transformation.actions.text.UpperCase) ArrayList(java.util.ArrayList) Absolute(org.talend.dataprep.transformation.actions.math.Absolute) ActionDefinition(org.talend.dataprep.api.action.ActionDefinition) DeleteInvalid(org.talend.dataprep.transformation.actions.delete.DeleteInvalid) FillIfEmpty(org.talend.dataprep.transformation.actions.fill.FillIfEmpty) DeleteEmpty(org.talend.dataprep.transformation.actions.delete.DeleteEmpty) FillInvalid(org.talend.dataprep.transformation.actions.fill.FillInvalid) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 ActionDefinition (org.talend.dataprep.api.action.ActionDefinition)1 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)1 DeleteEmpty (org.talend.dataprep.transformation.actions.delete.DeleteEmpty)1 DeleteInvalid (org.talend.dataprep.transformation.actions.delete.DeleteInvalid)1 FillIfEmpty (org.talend.dataprep.transformation.actions.fill.FillIfEmpty)1 FillInvalid (org.talend.dataprep.transformation.actions.fill.FillInvalid)1 Absolute (org.talend.dataprep.transformation.actions.math.Absolute)1 UpperCase (org.talend.dataprep.transformation.actions.text.UpperCase)1