Search in sources :

Example 91 with DataSetRow

use of org.talend.dataprep.api.dataset.row.DataSetRow 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()));
}
Also used : PatternFrequency(org.talend.dataprep.api.dataset.statistics.PatternFrequency) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Statistics(org.talend.dataprep.api.dataset.statistics.Statistics) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 92 with DataSetRow

use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.

the class SplitTest method should_split_underscore.

@Test
public void should_split_underscore() {
    // given
    final DataSetRow row = getRow("lorem bacon", "Bacon_ipsum", "01/01/2015");
    parameters.put(Split.SEPARATOR_PARAMETER, Split.OTHER_STRING);
    parameters.put(Split.MANUAL_SEPARATOR_PARAMETER_STRING, "_");
    final Map<String, String> expectedValues = new HashMap<>();
    expectedValues.put("0000", "lorem bacon");
    expectedValues.put("0001", "Bacon_ipsum");
    expectedValues.put("0003", "Bacon");
    expectedValues.put("0004", "ipsum");
    expectedValues.put("0002", "01/01/2015");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expectedValues, row.values());
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 93 with DataSetRow

use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.

the class SplitTest method should_split_row_no_separator.

@Test
public void should_split_row_no_separator() {
    // given
    final DataSetRow row = getRow("lorem bacon", "Bacon", "01/01/2015");
    final Map<String, String> expectedValues = new HashMap<>();
    expectedValues.put("0000", "lorem bacon");
    expectedValues.put("0001", "Bacon");
    expectedValues.put("0003", "Bacon");
    expectedValues.put("0004", "");
    expectedValues.put("0002", "01/01/2015");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expectedValues, row.values());
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 94 with DataSetRow

use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.

the class SplitTest method test_split_on_regex2.

@Test
public void test_split_on_regex2() {
    // given
    final DataSetRow row = getRow("lorem bacon", "Je vais bien (tout va bien)", "01/01/2015");
    parameters.put(Split.SEPARATOR_PARAMETER, Split.OTHER_REGEX);
    parameters.put(Split.MANUAL_SEPARATOR_PARAMETER_REGEX, "bien|fff");
    final Map<String, String> expectedValues = new HashMap<>();
    expectedValues.put("0000", "lorem bacon");
    expectedValues.put("0001", "Je vais bien (tout va bien)");
    expectedValues.put("0003", "Je vais ");
    expectedValues.put("0004", " (tout va bien)");
    expectedValues.put("0002", "01/01/2015");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expectedValues, row.values());
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Example 95 with DataSetRow

use of org.talend.dataprep.api.dataset.row.DataSetRow in project data-prep by Talend.

the class SplitTest method test_TDP_831_invalid_pattern.

@Test
public void test_TDP_831_invalid_pattern() {
    // given
    final Map<String, String> values = new HashMap<>();
    values.put("0000", "lorem bacon");
    values.put("0001", "Je vais bien (tout va bien)");
    values.put("0002", "01/01/2015");
    final DataSetRow row = new DataSetRow(values);
    parameters.put(Split.SEPARATOR_PARAMETER, Split.OTHER_REGEX);
    parameters.put(Split.MANUAL_SEPARATOR_PARAMETER_STRING, "(");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(values, row.values());
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest) Test(org.junit.Test)

Aggregations

DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)729 Test (org.junit.Test)688 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)518 HashMap (java.util.HashMap)235 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)111 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)81 LinkedHashMap (java.util.LinkedHashMap)45 RunnableAction (org.talend.dataprep.transformation.actions.common.RunnableAction)21 ActionContext (org.talend.dataprep.transformation.api.action.context.ActionContext)16 TransformationContext (org.talend.dataprep.transformation.api.action.context.TransformationContext)16 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)14 ArrayList (java.util.ArrayList)13 ChangeDatePatternTest (org.talend.dataprep.transformation.actions.date.ChangeDatePatternTest)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 AbstractTransformerWriterTest (org.talend.dataprep.transformation.api.transformer.AbstractTransformerWriterTest)12 List (java.util.List)11 PatternFrequency (org.talend.dataprep.api.dataset.statistics.PatternFrequency)11 DataSet (org.talend.dataprep.api.dataset.DataSet)10 Stream (java.util.stream.Stream)6 TDPException (org.talend.dataprep.exception.TDPException)6