Search in sources :

Example 76 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.

the class IntygModuleApiControllerIT method testReplaceIntyg.

@Test
public void testReplaceIntyg() {
    final String personnummer = "19121212-1212";
    RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
    changeOriginTo("DJUPINTEGRATION");
    String intygsId = createSignedIntyg("lisjp", personnummer);
    CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
    copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
    Map<String, String> pathParams = new HashMap<>();
    pathParams.put("intygsTyp", "lisjp");
    pathParams.put("intygsId", intygsId);
    final Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(200).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/ersatt").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(intygsId))).body("intygsTyp", equalTo("lisjp")).extract().response();
    JsonPath intygJson = new JsonPath(response.body().asString());
    String utkastId = intygJson.getString("intygsUtkastId");
    // Verify that the new draft has correct relations
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/lisjp/" + utkastId).then().body("relations.parent.intygsId", equalTo(intygsId)).body("relations.parent.relationKod", equalTo(RelationKod.ERSATT.name()));
    // Verify the original certficate has a child relationship
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get("moduleapi/intyg/lisjp/" + intygsId).then().body("relations.latestChildRelations.replacedByUtkast.intygsId", equalTo(utkastId)).body("relations.latestChildRelations.replacedByUtkast.relationKod", equalTo(RelationKod.ERSATT.name()));
}
Also used : Response(com.jayway.restassured.response.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) CopyIntygRequest(se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest) HashMap(java.util.HashMap) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Matchers.containsString(org.hamcrest.Matchers.containsString) JsonPath(com.jayway.restassured.path.json.JsonPath) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest) Test(org.junit.Test)

Example 77 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.

the class UtkastModuleApiControllerIT method testSaveDraft.

@Test
public void testSaveDraft() {
    RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
    String intygsTyp = "luse";
    String intygsId = createUtkast(intygsTyp, DEFAULT_PATIENT_PERSONNUMMER);
    Response responseIntyg = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-get-utkast-response-schema.json")).extract().response();
    JsonPath model = new JsonPath(responseIntyg.body().asString());
    String version = model.getString("version");
    Map<String, String> content = model.getJsonObject("content");
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(content).expect().statusCode(200).when().put(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId + "/" + version).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-save-draft-response-schema.json")).body("version", equalTo(Integer.parseInt(version) + 1));
}
Also used : Response(com.jayway.restassured.response.Response) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)

Example 78 with JsonPath

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

the class TaskRestServiceInteractionTest method verifyTaskCommentValues.

private void verifyTaskCommentValues(Comment mockTaskComment, String responseContent) {
    JsonPath path = from(responseContent);
    String returnedId = path.get("id");
    String returnedUserId = path.get("userId");
    String returnedTaskId = path.get("taskId");
    Date returnedTime = DateTimeUtil.parseDate(path.<String>get("time"));
    String returnedFullMessage = path.get("message");
    assertEquals(mockTaskComment.getId(), returnedId);
    assertEquals(mockTaskComment.getTaskId(), returnedTaskId);
    assertEquals(mockTaskComment.getUserId(), returnedUserId);
    assertEquals(mockTaskComment.getTime(), returnedTime);
    assertEquals(mockTaskComment.getFullMessage(), returnedFullMessage);
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) JsonPath(com.jayway.restassured.path.json.JsonPath) Date(java.util.Date)

Example 79 with JsonPath

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

the class DeploymentRestServiceInteractionTest method verifyDeploymentWithDefinitionsValues.

private void verifyDeploymentWithDefinitionsValues(Deployment mockDeployment, String responseContent) {
    JsonPath path = from(responseContent);
    verifyStandardDeploymentValues(mockDeployment, path);
    Map<String, HashMap<String, Object>> deployedProcessDefinitions = path.getMap(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS);
    Map<String, HashMap<String, Object>> deployedCaseDefinitions = path.getMap(PROPERTY_DEPLOYED_CASE_DEFINITIONS);
    Map<String, HashMap<String, Object>> deployedDecisionDefinitions = path.getMap(PROPERTY_DEPLOYED_DECISION_DEFINITIONS);
    Map<String, HashMap<String, Object>> deployedDecisionRequirementsDefinitions = path.getMap(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS);
    assertEquals(1, deployedProcessDefinitions.size());
    assertNotNull(deployedProcessDefinitions.get(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID));
    assertEquals(1, deployedCaseDefinitions.size());
    assertNotNull(deployedCaseDefinitions.get(EXAMPLE_CASE_DEFINITION_ID));
    assertEquals(1, deployedDecisionDefinitions.size());
    assertNotNull(deployedDecisionDefinitions.get(EXAMPLE_DECISION_DEFINITION_ID));
    assertEquals(1, deployedDecisionRequirementsDefinitions.size());
    assertNotNull(deployedDecisionRequirementsDefinitions.get(EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JsonPath(com.jayway.restassured.path.json.JsonPath)

Example 80 with JsonPath

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

the class DeploymentRestServiceInteractionTest method verifyDeploymentValuesEmptyDefinitions.

private void verifyDeploymentValuesEmptyDefinitions(Deployment mockDeployment, String responseContent) {
    JsonPath path = from(responseContent);
    verifyStandardDeploymentValues(mockDeployment, path);
    assertNull(path.get(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS));
    assertNull(path.get(PROPERTY_DEPLOYED_CASE_DEFINITIONS));
    assertNull(path.get(PROPERTY_DEPLOYED_DECISION_DEFINITIONS));
    assertNull(path.get(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath)

Aggregations

JsonPath (com.jayway.restassured.path.json.JsonPath)87 Test (org.junit.Test)56 Response (com.jayway.restassured.response.Response)29 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 Then (cucumber.api.java.en.Then)2 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 BaseMatcher (org.hamcrest.BaseMatcher)2 Description (org.hamcrest.Description)2 PreparationDTO (org.talend.dataprep.api.preparation.PreparationDTO)2