Search in sources :

Example 1 with ExportParameters

use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.

the class Export method onExecute.

/**
 * @param parameters the export parameters.
 * @return the request to perform.
 */
private HttpRequestBase onExecute(ExportParameters parameters) {
    try {
        final String parametersAsString = objectMapper.writerFor(ExportParameters.class).writeValueAsString(parameters);
        final HttpPost post = new HttpPost(transformationServiceUrl + "/apply");
        post.setEntity(new StringEntity(parametersAsString, ContentType.APPLICATION_JSON));
        return post;
    } catch (Exception e) {
        throw new TDPException(APIErrorCodes.UNABLE_TO_EXPORT_CONTENT, e);
    }
}
Also used : TDPException(org.talend.dataprep.exception.TDPException) HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) ExportParameters(org.talend.dataprep.api.export.ExportParameters) TDPException(org.talend.dataprep.exception.TDPException)

Example 2 with ExportParameters

use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.

the class AsyncAspectTest method shouldGetGroupIdFromAsyncGroupKeyAnnotation.

@Test
public void shouldGetGroupIdFromAsyncGroupKeyAnnotation() throws Exception {
    // given
    ExportParameters params = new ExportParameters();
    params.setDatasetId("ds#123");
    params.setPreparationId("prep#753");
    // when
    controller.groupNameFromAsyncGroupKeyAnnotation(params);
    // then
    assertGroupId(params.getPreparationId());
}
Also used : ExportParameters(org.talend.dataprep.api.export.ExportParameters) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ExportParameters

use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.

the class ExportParametersTest method noPreparationId.

@Test
public void noPreparationId() {
    // given parameters without preparation not dataset id
    ExportParameters params = new ExportParameters();
    params.setDatasetId("dataset#19843");
    // when
    Set<ConstraintViolation<ExportParameters>> constraintViolations = validator.validate(params);
    // then 1 violation (exportType is empty)
    Assert.assertEquals(1, constraintViolations.size());
}
Also used : ExportParameters(org.talend.dataprep.api.export.ExportParameters) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 4 with ExportParameters

use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.

the class ExportParametersTest method noDataSetId.

@Test
public void noDataSetId() {
    // given parameters without preparation not dataset id
    ExportParameters params = new ExportParameters();
    params.setPreparationId("prep#98435");
    // when
    Set<ConstraintViolation<ExportParameters>> constraintViolations = validator.validate(params);
    // then 1 violation (exportType is empty)
    Assert.assertEquals(1, constraintViolations.size());
}
Also used : ExportParameters(org.talend.dataprep.api.export.ExportParameters) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 5 with ExportParameters

use of org.talend.dataprep.api.export.ExportParameters in project data-prep by Talend.

the class ExportParametersTest method validInput.

@Test
public void validInput() {
    // given parameters without preparation not dataset id
    ExportParameters params = new ExportParameters();
    params.setDatasetId("dataset#19843");
    params.setExportType("TOTO");
    // when
    Set<ConstraintViolation<ExportParameters>> constraintViolations = validator.validate(params);
    // then no violation
    Assert.assertTrue(constraintViolations.isEmpty());
}
Also used : ExportParameters(org.talend.dataprep.api.export.ExportParameters) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Aggregations

ExportParameters (org.talend.dataprep.api.export.ExportParameters)40 Test (org.junit.Test)23 StreamingResponseBody (org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody)11 TDPException (org.talend.dataprep.exception.TDPException)11 Preparation (org.talend.dataprep.api.preparation.Preparation)10 DataSet (org.talend.dataprep.api.dataset.DataSet)9 TransformationCacheKey (org.talend.dataprep.cache.TransformationCacheKey)9 OutputStream (java.io.OutputStream)8 Configuration (org.talend.dataprep.transformation.api.transformer.configuration.Configuration)8 TransformationServiceBaseTest (org.talend.dataprep.transformation.service.TransformationServiceBaseTest)8 JsonParser (com.fasterxml.jackson.core.JsonParser)7 InputStream (java.io.InputStream)7 StringUtils (org.apache.commons.lang.StringUtils)7 Component (org.springframework.stereotype.Component)7 ServiceBaseTest (org.talend.ServiceBaseTest)7 ExportFormat (org.talend.dataprep.format.export.ExportFormat)7 CSVFormat (org.talend.dataprep.transformation.format.CSVFormat)7 BaseExportStrategy (org.talend.dataprep.transformation.service.BaseExportStrategy)7 ExportUtils (org.talend.dataprep.transformation.service.ExportUtils)7 InputStreamReader (java.io.InputStreamReader)6