use of org.talend.dataprep.transformation.preview.api.PreviewParameters in project data-prep by Talend.
the class DiffTest method should_return_preview.
@Test
public void should_return_preview() throws Exception {
// given
PreviewParameters input = new //
PreviewParameters(//
getSingleTransformation(), //
getMultipleTransformation(), //
createDataset("../preview/input.csv", "input4preview", "text/csv"), //
null, //
"[2,4,6]", HEAD);
// when
final String response = //
given().contentType(//
ContentType.JSON).body(//
mapper.writer().writeValueAsString(input)).when().expect().statusCode(200).log().ifError().post(//
"/transform/preview").asString();
// then
final String expected = IOUtils.toString(this.getClass().getResourceAsStream("../preview/expected_output.json"), UTF_8);
assertEquals(expected, response, false);
}
use of org.talend.dataprep.transformation.preview.api.PreviewParameters in project data-prep by Talend.
the class DiffTest method should_return_empty_array_when_step_does_not_create_columns.
@Test
public void should_return_empty_array_when_step_does_not_create_columns() throws Exception {
// given
final PreviewParameters previewParams = new //
PreviewParameters(//
getSingleTransformation(), //
getMultipleTransformationWithoutNewColumn(), //
createDataset("../preview/input.csv", "input4preview", "text/csv"), //
null, //
null, HEAD);
final List<PreviewParameters> input = Collections.singletonList(previewParams);
// when
final String response = //
given().contentType(//
ContentType.JSON).body(//
mapper.writer().writeValueAsString(input)).when().expect().statusCode(200).log().ifError().post("/transform/diff/metadata").asString();
// then
assertEquals("[{\"createdColumns\":[]}]", response, false);
}
use of org.talend.dataprep.transformation.preview.api.PreviewParameters in project data-prep by Talend.
the class DiffTest method test_TDP_1184.
/**
* After TDP-1184 fix, there is a problem on preview (regression?).
* Use case is:
* - delete a column (lastname here)
* - add new columns (with split on city here)
* - preview an action on the first new column (uppercase on 0000 here)
* <p>
* -> lastname is still on the preview data for lines 4 & 6. it is absent (which is what we expect) only for the first line!
*/
@Test
public void test_TDP_1184() throws Exception {
// given
PreviewParameters input = new //
PreviewParameters(//
getTransformation_TDP_1184_step_1(), //
getTransformation_TDP_1184_step_2(), //
createDataset("../preview/input.csv", "tdp-1184", "text/csv"), //
null, //
"[1,4,6]", HEAD);
// when
final String response = //
given().contentType(//
ContentType.JSON).body(//
mapper.writer().writeValueAsString(input)).when().expect().statusCode(200).log().ifError().post(//
"/transform/preview").asString();
// then
final InputStream expected = this.getClass().getResourceAsStream("../preview/expected_output_TDP_1184.json");
assertThat(response, sameJSONAsFile(expected));
}
use of org.talend.dataprep.transformation.preview.api.PreviewParameters in project data-prep by Talend.
the class DiffTest method should_return_created_columns_for_multiple_diffs.
@Test
public void should_return_created_columns_for_multiple_diffs() throws Exception {
// given
final String datasetId = createDataset("../preview/input.csv", "input4preview", "text/csv");
final PreviewParameters previewParams = new //
PreviewParameters(//
getSingleTransformation(), //
getMultipleTransformationWithNewColumn(), //
datasetId, //
null, //
null, HEAD);
final PreviewParameters previewParamsBis = new //
PreviewParameters(//
getMultipleTransformationWithNewColumn(), //
getMultipleTransformationWithNewColumnBis(), //
datasetId, //
null, //
null, HEAD);
final List<PreviewParameters> input = new ArrayList<>(2);
input.add(previewParams);
input.add(previewParamsBis);
// when
final String response = //
given().contentType(//
ContentType.JSON).body(//
mapper.writer().writeValueAsString(input)).when().expect().statusCode(200).log().ifError().post("/transform/diff/metadata").asString();
// then
assertEquals("[{\"createdColumns\":[\"0009\"]}, {\"createdColumns\":[\"0010\"]}]", response, false);
}
use of org.talend.dataprep.transformation.preview.api.PreviewParameters in project data-prep by Talend.
the class DiffTest method should_return_created_columns.
@Test
public void should_return_created_columns() throws Exception {
// given
final PreviewParameters previewParams = new //
PreviewParameters(//
getSingleTransformation(), //
getMultipleTransformationWithNewColumn(), //
createDataset("../preview/input.csv", "input4preview", "text/csv"), //
null, //
null, HEAD);
final List<PreviewParameters> input = Collections.singletonList(previewParams);
// when
final String response = //
given().contentType(//
ContentType.JSON).body(//
mapper.writer().writeValueAsString(input)).when().expect().statusCode(200).log().ifError().post("/transform/diff/metadata").asString();
// then
assertEquals("[{\"createdColumns\":[\"0009\"]}]", response, false);
}
Aggregations