use of org.talend.dataprep.transformation.aggregation.api.AggregationParameters in project data-prep by Talend.
the class AggregationTest method aggregateFromDataSet.
private String aggregateFromDataSet(String actions, String content) throws IOException {
// create the dataset
final String datasetId = createDataset(content, "aggregateFromDataSet input " + Instant.now().getEpochSecond(), "text/csv");
// update the actions
final String actionsAsJson = IOUtils.toString(this.getClass().getResourceAsStream(actions), UTF_8);
final AggregationParameters parameters = mapper.readerFor(AggregationParameters.class).readValue(actionsAsJson);
parameters.setDatasetId(datasetId);
parameters.setPreparationId(null);
parameters.setStepId(null);
return //
given().body(//
mapper.writer().writeValueAsString(parameters)).contentType(//
APPLICATION_JSON_VALUE).when().expect().statusCode(200).log().ifError().post(//
"/aggregate").asString();
}
use of org.talend.dataprep.transformation.aggregation.api.AggregationParameters in project data-prep by Talend.
the class AggregationServiceTest method shouldNotAggregateBecauseNoGroupBy.
@Test(expected = TDPException.class)
public void shouldNotAggregateBecauseNoGroupBy() {
final AggregationParameters params = new AggregationParameters();
params.addOperation(new AggregationOperation("0001", Operator.AVERAGE));
service.aggregate(params, new DataSet());
}
use of org.talend.dataprep.transformation.aggregation.api.AggregationParameters in project data-prep by Talend.
the class AggregationAPITest method should_not_aggregate_because_dataset_and_preparation_id_are_missing.
@Test
public void should_not_aggregate_because_dataset_and_preparation_id_are_missing() throws IOException {
// given
AggregationParameters params = getAggregationParameters("aggregation/aggregation_parameters.json");
params.setDatasetId(null);
params.setPreparationId(null);
// when
final Response response = //
given().contentType(ContentType.JSON).body(//
mapper.writer().writeValueAsString(params)).when().post("/api/aggregate");
// then
assertEquals(406, response.getStatusCode());
}
use of org.talend.dataprep.transformation.aggregation.api.AggregationParameters in project data-prep by Talend.
the class AggregationAPITest method should_not_aggregate_because_dataset_and_preparation_id_are_set.
@Test
public void should_not_aggregate_because_dataset_and_preparation_id_are_set() throws IOException {
// given
AggregationParameters params = getAggregationParameters("aggregation/aggregation_parameters.json");
params.setDatasetId("ds#753874");
// when
final Response response = //
given().contentType(ContentType.JSON).body(//
mapper.writer().writeValueAsString(params)).when().post("/api/aggregate");
// then
assertEquals(400, response.getStatusCode());
}
Aggregations