Search in sources :

Example 91 with ColumnMetadata

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

the class ComputeTimeSinceTest method testAdapt.

@Test
public void testAdapt() throws Exception {
    Assert.assertThat(action.adapt((ColumnMetadata) null), is(action));
    ColumnMetadata column = column().name("myColumn").id(0).type(Type.STRING).build();
    Assert.assertThat(action.adapt(column), is(action));
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) Test(org.junit.Test)

Example 92 with ColumnMetadata

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

the class ComputeTimeSinceTest method should_update_metadata_twice_diff_units.

@Test
public void should_update_metadata_twice_diff_units() throws IOException {
    // given
    final DataSetRow row = getDefaultRow("statistics_MM_dd_yyyy.json");
    final List<ColumnMetadata> expected = new ArrayList<>();
    expected.add(createMetadata("0000", "recipe"));
    expected.add(createMetadata("0001", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
    expected.add(createMetadata("0004", "since_last update_in_days", Type.INTEGER));
    expected.add(createMetadata("0003", "since_last update_in_years", Type.INTEGER));
    expected.add(createMetadata("0002", "steps"));
    // when
    parameters.put(TIME_UNIT_PARAMETER, YEARS.name());
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    parameters.put(TIME_UNIT_PARAMETER, DAYS.name());
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expected, row.getRowMetadata().getColumns());
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) ArrayList(java.util.ArrayList) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Example 93 with ColumnMetadata

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

the class ComputeTimeSinceTest method should_update_metadata.

@Test
public void should_update_metadata() throws IOException {
    // given
    final DataSetRow row = getDefaultRow("statistics_MM_dd_yyyy.json");
    final List<ColumnMetadata> expected = new ArrayList<>();
    expected.add(createMetadata("0000", "recipe"));
    expected.add(createMetadata("0001", "last update", Type.DATE, "statistics_MM_dd_yyyy.json"));
    expected.add(createMetadata("0003", "since_last update_in_years", Type.INTEGER));
    expected.add(createMetadata("0002", "steps"));
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    assertEquals(expected, row.getRowMetadata().getColumns());
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) ArrayList(java.util.ArrayList) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Example 94 with ColumnMetadata

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

the class DomainChangeTest method init.

@Before
public void init() {
    final Map<String, String> values = new HashMap<>();
    values.put("0000", "David Bowie");
    values.put("0001", "");
    values.put("0002", "Something");
    row = new DataSetRow(values);
    final RowMetadata rowMetadata = row.getRowMetadata();
    ColumnMetadata columnMetadata = rowMetadata.getById("0002");
    columnMetadata.setType(Type.INTEGER.getName());
    columnMetadata.setDomain("FR_BEER");
    columnMetadata.setDomainFrequency(1);
    columnMetadata.setDomainLabel("French Beer");
    parameters = new HashMap<>();
    parameters.put(ImplicitParameters.SCOPE.getKey().toLowerCase(), "column");
    parameters.put(ImplicitParameters.COLUMN_ID.getKey().toLowerCase(), "0002");
    parameters.put(NEW_DOMAIN_ID_PARAMETER_KEY, "AUS_BEER");
    parameters.put(NEW_DOMAIN_LABEL_PARAMETER_KEY, "Australian Beer");
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) HashMap(java.util.HashMap) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Before(org.junit.Before)

Example 95 with ColumnMetadata

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

the class DomainChangeTest method test_apply_inplace.

@Test
public void test_apply_inplace() throws Exception {
    // when
    ActionTestWorkbench.test(row, actionRegistry, factory.create(action, parameters));
    // then
    final ColumnMetadata column = row.getRowMetadata().getById("0002");
    assertThat(column.getDomain()).isEqualTo("AUS_BEER");
    assertThat(column.getDomainLabel()).isEqualTo("Australian Beer");
}
Also used : ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) Test(org.junit.Test) AbstractMetadataBaseTest(org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)

Aggregations

ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)320 Test (org.junit.Test)217 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)115 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)86 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)80 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)48 InputStream (java.io.InputStream)25 Type (org.talend.dataprep.api.type.Type)23 DataSetBaseTest (org.talend.dataprep.dataset.DataSetBaseTest)22 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)17 IOException (java.io.IOException)14 TDPException (org.talend.dataprep.exception.TDPException)14 Schema (org.talend.dataprep.schema.Schema)14 Autowired (org.springframework.beans.factory.annotation.Autowired)13 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 SemanticDomain (org.talend.dataprep.api.dataset.statistics.SemanticDomain)12 DataSetServiceTest (org.talend.dataprep.dataset.service.DataSetServiceTest)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10