Search in sources :

Example 41 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project dataverse by IQSS.

the class UtilIT method getDataverseIdFromResponse.

static Integer getDataverseIdFromResponse(Response createDataverseResponse) {
    JsonPath createdDataverse = JsonPath.from(createDataverseResponse.body().asString());
    int dataverseId = createdDataverse.getInt("data.id");
    logger.info("Id found in create dataverse response: " + createdDataverse);
    return dataverseId;
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 42 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project dataverse by IQSS.

the class UtilIT method getApiTokenFromResponse.

static String getApiTokenFromResponse(Response createUserResponse) {
    JsonPath createdUser = JsonPath.from(createUserResponse.body().asString());
    String apiToken = createdUser.getString("data." + API_TOKEN_KEY);
    logger.info("API token found in create user response: " + apiToken);
    return apiToken;
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 43 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project dataverse by IQSS.

the class UtilIT method getAliasFromResponse.

static String getAliasFromResponse(Response createDataverseResponse) {
    JsonPath createdDataverse = JsonPath.from(createDataverseResponse.body().asString());
    String alias = createdDataverse.getString("data.alias");
    logger.info("Alias found in create dataverse response: " + alias);
    return alias;
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 44 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project dataverse by IQSS.

the class FileRecordJobIT method getFaileJobJson.

/**
 * A failed job is expected, get the json failure response
 * @return
 */
private JsonPath getFaileJobJson() {
    System.out.println("JOB API: " + props.getProperty("filesystem.api") + "/" + dsDoi);
    JsonPath jsonPath = given().header(API_TOKEN_HTTP_HEADER, token).post(props.getProperty("filesystem.api") + "/" + dsDoi).then().assertThat().statusCode(400).extract().jsonPath();
    return jsonPath;
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 45 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project camunda-bpm-platform by camunda.

the class TaskRestServiceInteractionTest method verifyTaskAttachmentValues.

private void verifyTaskAttachmentValues(Attachment mockTaskAttachment, String responseContent, boolean urlExist) {
    JsonPath path = from(responseContent);
    String returnedId = path.get("id");
    String returnedTaskId = path.get("taskId");
    String returnedName = path.get("name");
    String returnedType = path.get("type");
    String returnedDescription = path.get("description");
    String returnedUrl = path.get("url");
    Attachment mockAttachment = mockTaskAttachments.get(0);
    assertEquals(mockAttachment.getId(), returnedId);
    assertEquals(mockAttachment.getTaskId(), returnedTaskId);
    assertEquals(mockAttachment.getName(), returnedName);
    assertEquals(mockAttachment.getType(), returnedType);
    assertEquals(mockAttachment.getDescription(), returnedDescription);
    if (urlExist) {
        assertEquals(mockAttachment.getUrl(), returnedUrl);
    }
}
Also used : Attachment(org.camunda.bpm.engine.task.Attachment) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) JsonPath(com.jayway.restassured.path.json.JsonPath)

Aggregations

JsonPath (com.jayway.restassured.path.json.JsonPath)83 Test (org.junit.Test)56 Response (com.jayway.restassured.response.Response)25 BaseRestTest (integration.BaseRestTest)11 BaseRestIntegrationTest (se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)10 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)9 Matchers.anyString (org.mockito.Matchers.anyString)8 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 Ignore (org.junit.Ignore)5 MongoDbSeed (integration.MongoDbSeed)4 HashMap (java.util.HashMap)3 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 BaseMatcher (org.hamcrest.BaseMatcher)2 Description (org.hamcrest.Description)2 UserPreparation (org.talend.dataprep.preparation.service.UserPreparation)2 Application (org.talend.dataprep.transformation.Application)2