Search in sources :

Example 1 with MockTDPException

use of org.talend.dataprep.test.MockTDPException in project data-prep by Talend.

the class PreparationClientTest method getDetails.

/**
 * Return the details of a preparation at a given (optional) step.
 *
 * @param preparationId the wanted preparation id.
 * @param wantedStepId the optional wanted step id.
 * @return the details of a preparation at a given (optional) step.
 */
public PreparationMessage getDetails(String preparationId, String wantedStepId) {
    final RequestSpecification specs = given();
    if (StringUtils.isNotBlank(wantedStepId)) {
        specs.queryParam("stepId", wantedStepId);
    }
    final Response response = specs.when().get("/preparations/{id}/details", preparationId);
    if (response.getStatusCode() != 200) {
        throw new MockTDPException(response);
    }
    try {
        return mapper.readerFor(PreparationMessage.class).readValue(response.asString());
    } catch (IOException e) {
        throw new TDPException(UNABLE_TO_READ_CONTENT);
    }
}
Also used : Response(com.jayway.restassured.response.Response) TDPException(org.talend.dataprep.exception.TDPException) MockTDPException(org.talend.dataprep.test.MockTDPException) MockTDPException(org.talend.dataprep.test.MockTDPException) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) PreparationMessage(org.talend.dataprep.api.preparation.PreparationMessage) IOException(java.io.IOException)

Aggregations

Response (com.jayway.restassured.response.Response)1 RequestSpecification (com.jayway.restassured.specification.RequestSpecification)1 IOException (java.io.IOException)1 PreparationMessage (org.talend.dataprep.api.preparation.PreparationMessage)1 TDPException (org.talend.dataprep.exception.TDPException)1 MockTDPException (org.talend.dataprep.test.MockTDPException)1