Search in sources :

Example 71 with RowMetadata

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

the class FolderServiceTest method searchFolderShouldUpdateNbPreparationsFound.

@Test
public void searchFolderShouldUpdateNbPreparationsFound() throws Exception {
    // given
    createFolder(home.getId(), "foo");
    final Folder foo = getFolder(home.getId(), "foo");
    Preparation preparation = new Preparation();
    preparation.setName("test_name");
    preparation.setDataSetId("1234");
    preparation.setRowMetadata(new RowMetadata());
    clientTest.createPreparation(preparation, foo.getId());
    // when
    final Response response = // 
    given().queryParam("name", // 
    "foo").expect().statusCode(200).log().ifError().when().get("/folders/search");
    // then
    final List<Folder> folders = mapper.readValue(response.asString(), new TypeReference<List<Folder>>() {
    });
    assertThat(folders, hasSize(1));
    final Folder folder = folders.get(0);
    assertThat(folder.getName(), is("foo"));
    assertEquals(1, folder.getNbPreparations());
}
Also used : Response(com.jayway.restassured.response.Response) Preparation(org.talend.dataprep.api.preparation.Preparation) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Folder(org.talend.dataprep.api.folder.Folder) Test(org.junit.Test) BasePreparationTest(org.talend.dataprep.preparation.BasePreparationTest)

Example 72 with RowMetadata

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

the class MetadataChangesOnActionsGeneratorTest method getActionCreatedColumns_should_return_created_columns_for_multiple_diffs.

@Test
public void getActionCreatedColumns_should_return_created_columns_for_multiple_diffs() throws Exception {
    // given
    RowMetadata workingMetadata = new RowMetadata();
    workingMetadata.addColumn(createColumnNamed("do"));
    workingMetadata.addColumn(createColumnNamed("ré"));
    workingMetadata.addColumn(createColumnNamed("mi"));
    // when
    // 
    doAnswer(answer(newArrayList("foo", "bar"), emptyList(), null)).when(// 
    firstRowAction).compile(// 
    any(ActionContext.class));
    // 
    doAnswer(answer(emptyList(), newArrayList("do", "ré"), null)).when(// s
    secondRowAction).compile(// 
    any(ActionContext.class));
    StepDiff stepDiff = onActionsGenerator.computeCreatedColumns(newArrayList(firstAction, secondAction), workingMetadata);
    // then
    assertEquals(newArrayList("0003", "0004"), stepDiff.getCreatedColumns());
}
Also used : RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) StepDiff(org.talend.dataprep.api.preparation.StepDiff) ActionContext(org.talend.dataprep.transformation.api.action.context.ActionContext) Test(org.junit.Test)

Example 73 with RowMetadata

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

the class MetadataChangesOnActionsGeneratorTest method getActionCreatedColumns_should_cleanup_transformation_context.

@Test
public void getActionCreatedColumns_should_cleanup_transformation_context() throws Exception {
    // given
    RowMetadata workingMetadata = new RowMetadata();
    workingMetadata.addColumn(createColumnNamed("do"));
    // when
    // 
    doAnswer(answer(emptyList(), emptyList(), firstActionStuffInActionContext)).when(// 
    firstRowAction).compile(// 
    any(ActionContext.class));
    // 
    doAnswer(answer(emptyList(), emptyList(), secondActionStuffInActionContext)).when(// 
    secondRowAction).compile(// 
    any(ActionContext.class));
    onActionsGenerator.computeCreatedColumns(newArrayList(firstAction, secondAction), workingMetadata);
    // then
    verify(firstActionStuffInActionContext).destroy();
    verify(secondActionStuffInActionContext).destroy();
}
Also used : RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) ActionContext(org.talend.dataprep.transformation.api.action.context.ActionContext) Test(org.junit.Test)

Example 74 with RowMetadata

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

the class MetadataChangesOnActionsGeneratorTest method getActionCreatedColumns_firstActionCreatedColumnDoesNotCount.

@Test
public void getActionCreatedColumns_firstActionCreatedColumnDoesNotCount() throws Exception {
    // given
    RowMetadata rowMetadata = new RowMetadata();
    rowMetadata.addColumn(createColumnNamed("do"));
    rowMetadata.addColumn(createColumnNamed("ré"));
    rowMetadata.addColumn(createColumnNamed("mi"));
    // when
    // 
    doAnswer(answer(newArrayList("foo", "bar"), emptyList(), firstActionStuffInActionContext)).when(// 
    firstRowAction).compile(// 
    any(ActionContext.class));
    // 
    doAnswer(answer(newArrayList("beer"), newArrayList("do", "ré"), secondActionStuffInActionContext)).when(// 
    secondRowAction).compile(// 
    any(ActionContext.class));
    StepDiff diff = onActionsGenerator.computeCreatedColumns(rowMetadata, newArrayList(firstAction), newArrayList(secondAction));
    // then
    assertEquals(newArrayList("0005"), diff.getCreatedColumns());
}
Also used : RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) StepDiff(org.talend.dataprep.api.preparation.StepDiff) ActionContext(org.talend.dataprep.transformation.api.action.context.ActionContext) Test(org.junit.Test)

Example 75 with RowMetadata

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

the class PreparationServiceTest method init.

private void init() throws IOException {
    createFolder(home.getId(), "foo");
    final Folder foo = getFolder(home.getId(), "foo");
    createFolder(home.getId(), "Folder Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
    final Folder specialChar = getFolder(home.getId(), "Folder Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
    Preparation preparation = new Preparation();
    preparation.setName("prep_name_foo");
    preparation.setDataSetId("1234");
    preparation.setRowMetadata(new RowMetadata());
    clientTest.createPreparation(preparation, foo.getId());
    preparation.setName("prep_name_home");
    clientTest.createPreparation(preparation, home.getId());
    preparation.setName("Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
    clientTest.createPreparation(preparation, foo.getId());
    preparation.setName("Cr((eate Email A!ddressrrrbb[zzzz (copie-é'(-è_çà)+&.csv");
    clientTest.createPreparation(preparation, specialChar.getId());
}
Also used : Preparation(org.talend.dataprep.api.preparation.Preparation) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Folder(org.talend.dataprep.api.folder.Folder)

Aggregations

RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)199 Test (org.junit.Test)130 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)112 ColumnMetadata (org.talend.dataprep.api.dataset.ColumnMetadata)87 AbstractMetadataBaseTest (org.talend.dataprep.transformation.actions.AbstractMetadataBaseTest)68 HashMap (java.util.HashMap)48 ActionContext (org.talend.dataprep.transformation.api.action.context.ActionContext)21 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)20 RunnableAction (org.talend.dataprep.transformation.actions.common.RunnableAction)19 TransformationContext (org.talend.dataprep.transformation.api.action.context.TransformationContext)18 ArrayList (java.util.ArrayList)16 DataSet (org.talend.dataprep.api.dataset.DataSet)11 List (java.util.List)9 Statistics (org.talend.dataprep.api.dataset.statistics.Statistics)9 Before (org.junit.Before)7 SemanticDomain (org.talend.dataprep.api.dataset.statistics.SemanticDomain)6 Preparation (org.talend.dataprep.api.preparation.Preparation)6 Response (com.jayway.restassured.response.Response)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Logger (org.slf4j.Logger)5