Search in sources :

Example 41 with DataSetRow

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

the class AbsoluteTest method testAbsoluteFloatWithEmpty.

@Test
public void testAbsoluteFloatWithEmpty() {
    // given
    final Map<String, String> values = new HashMap<>();
    // $NON-NLS-1$
    values.put(FLOAT_COLUMN, "");
    final DataSetRow row = new DataSetRow(values);
    assertFloat(row, "");
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 42 with DataSetRow

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

the class AbsoluteTest method test_AbsoluteFloatWithHugeNegativeValue.

@Test
public void test_AbsoluteFloatWithHugeNegativeValue() {
    // given
    final Map<String, String> values = new HashMap<>();
    // $NON-NLS-1$
    values.put(FLOAT_COLUMN, "-12345678.1");
    final DataSetRow row = new DataSetRow(values);
    assertFloat(row, "12345678.1");
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 43 with DataSetRow

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

the class AbsoluteTest method testAbsoluteFloatWithNegativeZero.

@Test
public void testAbsoluteFloatWithNegativeZero() {
    // given
    final Map<String, String> values = new HashMap<>();
    // $NON-NLS-1$
    values.put(FLOAT_COLUMN, "-0");
    final DataSetRow row = new DataSetRow(values);
    assertFloat(row, "0");
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 44 with DataSetRow

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

the class AbsoluteTest method testAbsoluteFloatWithNegativePercentage.

@Test
public void testAbsoluteFloatWithNegativePercentage() {
    // given
    final Map<String, String> values = new HashMap<>();
    // $NON-NLS-1$
    values.put(FLOAT_COLUMN, "-5%");
    final DataSetRow row = new DataSetRow(values);
    assertFloat(row, "0.05");
}
Also used : HashMap(java.util.HashMap) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Example 45 with DataSetRow

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

the class ChangeNumberFormatTest method should_process_row_alt_seps.

@Test
public void should_process_row_alt_seps() throws Exception {
    // given
    final DataSetRow row = getRow("toto", "1_012/50", "tata");
    parameters.put(FROM_SEPARATORS, CUSTOM);
    parameters.put(FROM + DECIMAL + SEPARATOR, "/");
    parameters.put(FROM + GROUPING + SEPARATOR, "_");
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final DataSetRow expectedRow = getRow("toto", "1,012.5", "tata");
    assertEquals(expectedRow.values(), row.values());
}
Also used : DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

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