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());
}
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());
}
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();
}
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());
}
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());
}
Aggregations