Search in sources :

Example 1 with RequestSpecification

use of com.jayway.restassured.specification.RequestSpecification 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)

Example 2 with RequestSpecification

use of com.jayway.restassured.specification.RequestSpecification in project dataverse by IQSS.

the class UtilIT method returnDatasetToAuthor.

static Response returnDatasetToAuthor(String datasetPersistentId, JsonObject jsonObject, String apiToken) {
    String jsonIn = jsonObject.toString();
    RequestSpecification requestSpecification = given();
    if (apiToken != null) {
        requestSpecification = given().header(UtilIT.API_TOKEN_HTTP_HEADER, apiToken).body(jsonIn).contentType("application/json");
    }
    return requestSpecification.post("/api/datasets/:persistentId/returnToAuthor?persistentId=" + datasetPersistentId);
}
Also used : RequestSpecification(com.jayway.restassured.specification.RequestSpecification)

Example 3 with RequestSpecification

use of com.jayway.restassured.specification.RequestSpecification in project dataverse by IQSS.

the class UtilIT method dataCaptureModuleChecksumValidation.

static Response dataCaptureModuleChecksumValidation(String datasetPersistentId, JsonObject jsonObject, String apiToken) {
    // Assume it's a number.
    String persistentIdInPath = datasetPersistentId;
    // If datasetPersistentId is a number we'll just put it in the path.
    String optionalQueryParam = "";
    if (!NumberUtils.isNumber(datasetPersistentId)) {
        persistentIdInPath = ":persistentId";
        optionalQueryParam = "?persistentId=" + datasetPersistentId;
    }
    RequestSpecification requestSpecification = given();
    if (apiToken != null) {
        requestSpecification = given().body(jsonObject.toString()).contentType(ContentType.JSON).header(UtilIT.API_TOKEN_HTTP_HEADER, apiToken);
    }
    return requestSpecification.post("/api/datasets/" + persistentIdInPath + "/dataCaptureModule/checksumValidation" + optionalQueryParam);
}
Also used : RequestSpecification(com.jayway.restassured.specification.RequestSpecification)

Example 4 with RequestSpecification

use of com.jayway.restassured.specification.RequestSpecification in project camunda-bpm-platform by camunda.

the class AuthorizationRestServiceQueryTest method testCompleteGetParameters.

@Test
public void testCompleteGetParameters() {
    List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
    AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);
    Map<String, String> queryParameters = getCompleteStringQueryParameters();
    RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
    for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
        requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
    }
    requestSpecification.expect().statusCode(Status.OK.getStatusCode()).when().get(SERVICE_PATH);
    verify(mockQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID);
    verify(mockQuery).authorizationType(MockProvider.EXAMPLE_AUTHORIZATION_TYPE);
    verify(mockQuery).userIdIn(new String[] { MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_ID2 });
    verify(mockQuery).groupIdIn(new String[] { MockProvider.EXAMPLE_GROUP_ID, MockProvider.EXAMPLE_GROUP_ID2 });
    verify(mockQuery).resourceType(MockProvider.EXAMPLE_RESOURCE_TYPE_ID);
    verify(mockQuery).resourceId(MockProvider.EXAMPLE_RESOURCE_ID);
    verify(mockQuery).list();
}
Also used : Authorization(org.camunda.bpm.engine.authorization.Authorization) AuthorizationQuery(org.camunda.bpm.engine.authorization.AuthorizationQuery) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) Test(org.junit.Test)

Example 5 with RequestSpecification

use of com.jayway.restassured.specification.RequestSpecification in project camunda-bpm-platform by camunda.

the class GroupRestServiceQueryTest method testCompleteGetParameters.

@Test
public void testCompleteGetParameters() {
    Map<String, String> queryParameters = getCompleteStringQueryParameters();
    RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
    for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
        requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
    }
    requestSpecification.expect().statusCode(Status.OK.getStatusCode()).when().get(GROUP_QUERY_URL);
    verify(mockQuery).groupName(MockProvider.EXAMPLE_GROUP_NAME);
    verify(mockQuery).groupNameLike("%" + MockProvider.EXAMPLE_GROUP_NAME + "%");
    verify(mockQuery).groupType(MockProvider.EXAMPLE_GROUP_TYPE);
    verify(mockQuery).groupMember(MockProvider.EXAMPLE_USER_ID);
    verify(mockQuery).memberOfTenant(MockProvider.EXAMPLE_TENANT_ID);
    verify(mockQuery).list();
}
Also used : RequestSpecification(com.jayway.restassured.specification.RequestSpecification) Test(org.junit.Test)

Aggregations

RequestSpecification (com.jayway.restassured.specification.RequestSpecification)13 Test (org.junit.Test)4 Response (com.jayway.restassured.response.Response)2 IOException (java.io.IOException)1 Authorization (org.camunda.bpm.engine.authorization.Authorization)1 AuthorizationQuery (org.camunda.bpm.engine.authorization.AuthorizationQuery)1 PreparationMessage (org.talend.dataprep.api.preparation.PreparationMessage)1 TDPException (org.talend.dataprep.exception.TDPException)1 MockTDPException (org.talend.dataprep.test.MockTDPException)1