Search in sources :

Example 6 with AggregationParameters

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();
}
Also used : AggregationParameters(org.talend.dataprep.transformation.aggregation.api.AggregationParameters)

Example 7 with AggregationParameters

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());
}
Also used : DataSet(org.talend.dataprep.api.dataset.DataSet) AggregationParameters(org.talend.dataprep.transformation.aggregation.api.AggregationParameters) AggregationOperation(org.talend.dataprep.transformation.aggregation.api.AggregationOperation) Test(org.junit.Test) TransformationBaseTest(org.talend.dataprep.transformation.TransformationBaseTest)

Example 8 with AggregationParameters

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());
}
Also used : Response(com.jayway.restassured.response.Response) AggregationParameters(org.talend.dataprep.transformation.aggregation.api.AggregationParameters) Test(org.junit.Test)

Example 9 with AggregationParameters

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());
}
Also used : Response(com.jayway.restassured.response.Response) AggregationParameters(org.talend.dataprep.transformation.aggregation.api.AggregationParameters) Test(org.junit.Test)

Aggregations

AggregationParameters (org.talend.dataprep.transformation.aggregation.api.AggregationParameters)9 Test (org.junit.Test)7 Response (com.jayway.restassured.response.Response)2 DataSet (org.talend.dataprep.api.dataset.DataSet)2 JsonParser (com.fasterxml.jackson.core.JsonParser)1 ApiOperation (io.swagger.annotations.ApiOperation)1 StreamingResponseBody (org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody)1 ExportParameters (org.talend.dataprep.api.export.ExportParameters)1 DataSetGet (org.talend.dataprep.command.dataset.DataSetGet)1 TDPException (org.talend.dataprep.exception.TDPException)1 VolumeMetered (org.talend.dataprep.metrics.VolumeMetered)1 TransformationBaseTest (org.talend.dataprep.transformation.TransformationBaseTest)1 AggregationOperation (org.talend.dataprep.transformation.aggregation.api.AggregationOperation)1