Search in sources :

Example 31 with JsonPath

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

the class UtkastModuleApiControllerIT method testValidateDraft.

@Test
public void testValidateDraft() {
    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());
    Map<String, String> content = model.getJsonObject("content");
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(content).pathParams("intygsTyp", intygsTyp, "intygsId", intygsId).expect().statusCode(200).when().post(MODULEAPI_UTKAST_BASE + "/{intygsTyp}/{intygsId}/validate").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-validate-draft-response-schema.json"));
}
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 32 with JsonPath

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

the class UtkastModuleApiControllerIT method testServerSigneraUtkastMedGrp.

@Test
public void testServerSigneraUtkastMedGrp() throws IOException {
    FakeElegCredentials fakeElegCredentials = new FakeElegCredentials();
    fakeElegCredentials.setPersonId(TOLVAN_PERSON_ID);
    fakeElegCredentials.setPrivatLakare(true);
    RestAssured.sessionId = getAuthSession(fakeElegCredentials);
    Intyg intyg = createIntyg();
    // var knownSignStatuses = {'BEARBETAR':'', 'VANTA_SIGN':'', 'NO_CLIENT':'', 'SIGNERAD':'', 'OKAND': ''};
    // Påbörja signering
    Response responseTicket = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().post(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + intyg.getId() + "/" + intyg.getVersion() + "/grp/signeraserver").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json")).body("status", equalTo("BEARBETAR")).extract().response();
    // Hämta ut biljett-id från svaret
    JsonPath model = new JsonPath(responseTicket.body().asString());
    String biljettId = model.getString("id");
    // biljettId är inte samma sak som orderRef.
    // Hämta ut orderRef först
    Response responseOrderRef = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.TEXT).expect().statusCode(200).when().get(GRPAPI_STUBBE_BASE + "/orderref/" + biljettId).then().extract().response();
    String orderRef = responseOrderRef.body().asString();
    // Ändra GRP-status till USER_SIGN och kontrollera
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(createGrpSignatureStatus(orderRef, ProgressStatusType.USER_SIGN)).expect().statusCode(200).when().put(GRPAPI_STUBBE_BASE + "/status");
    // Simulera väntetid vid pollning mot riktig GPR-tjänst
    sleep();
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + biljettId + "/signeringsstatus").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json")).body("status", equalTo("VANTA_SIGN"));
    // Ändra GRP-status till COMPLETE och kontrollera
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(createGrpSignatureStatus(orderRef, ProgressStatusType.COMPLETE)).expect().statusCode(200).when().put(GRPAPI_STUBBE_BASE + "/status");
    // Simulera väntetid vid pollning mot riktig GPR-tjänst
    sleep();
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + biljettId + "/signeringsstatus").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json")).body("status", equalTo("SIGNERAD"));
}
Also used : Response(com.jayway.restassured.response.Response) FakeElegCredentials(se.inera.intyg.webcert.web.auth.eleg.FakeElegCredentials) 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 33 with JsonPath

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

the class UtkastModuleApiControllerIT method testSigneraUtkastInvalidState.

@Test
public void testSigneraUtkastInvalidState() {
    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");
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(500).when().post(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId + "/" + version + "/signeringshash").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-error-response-schema.json")).body("errorCode", equalTo(WebCertServiceErrorCodeEnum.INVALID_STATE.name())).body("message", not(isEmptyString()));
}
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 34 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project joynr by bmwcarit.

the class ClusteredBounceProxyControllerTest method testBounceProxyRegistrationAtBpc2.

@Test
@Ignore("Ignore until servers are started in a separate JVM. Guice static problem")
public void testBounceProxyRegistrationAtBpc2() throws InterruptedException {
    RestAssured.baseURI = bpcUrl2;
    Response responseRegister = given().log().all().queryParam("url4cc", "http://testurl/url4cc").and().queryParam("url4bpc", "http://testurl/url4bpc").when().put("bounceproxies/?bpid=1.0");
    assertEquals(201, /* Created */
    responseRegister.getStatusCode());
    waitForReplication();
    RestAssured.baseURI = bpcUrl1;
    JsonPath listBps = given().log().all().get("bounceproxies").body().jsonPath();
    assertThat(listBps, containsBounceProxy("1.0", "ALIVE"));
}
Also used : Response(com.jayway.restassured.response.Response) JsonPath(com.jayway.restassured.path.json.JsonPath) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project joynr by bmwcarit.

the class MultipleControlledBounceProxiesTest method testSimpleChannelSetupOnTwoBounceProxies.

@Test
@Ignore("need cleanup of other tests (i.e. implementation of delete channel")
public void testSimpleChannelSetupOnTwoBounceProxies() throws Exception {
    // get bounce proxies list
    /* @formatter:off */
    JsonPath listBps = given().get("bounceproxies").getBody().jsonPath();
    /* @formatter:on */
    assertThat(listBps, allOf(// 
    anyOf(containsBounceProxy("X.Y", "ALIVE"), containsBounceProxy("X.Y", "ACTIVE")), anyOf(containsBounceProxy("A.B", "ALIVE"), containsBounceProxy("A.B", "ACTIVE"))));
    // create channel on bounce proxy
    /* @formatter:off */
    // 
    Response responseCreateFirstChannel = given().header(X_ATMOSPHERE_TRACKING_ID, "trackingId-123").post("channels?ccid=channel-123");
    /* @formatter:on */
    assertEquals(201, /* Created */
    responseCreateFirstChannel.getStatusCode());
    assertEquals("X.Y", responseCreateFirstChannel.getHeader(HEADER_BOUNCEPROXY_ID));
    assertEquals("http://www.joynX.de/bp/channels/channel-123" + SESSIONID_APPENDIX + ".Y", responseCreateFirstChannel.getHeader(HEADER_LOCATION));
    // create channel on different bounce proxy
    /* @formatter:off */
    // 
    Response responseCreateSecondChannel = given().header(X_ATMOSPHERE_TRACKING_ID, "trackingId-abc").post("channels?ccid=channel-abc");
    /* @formatter:on */
    assertEquals(201, /* Created */
    responseCreateSecondChannel.getStatusCode());
    assertEquals("A.B", responseCreateSecondChannel.getHeader(HEADER_BOUNCEPROXY_ID));
    assertEquals("http://www.joynA.de/bp/channels/channel-abc" + SESSIONID_APPENDIX + ".B", responseCreateSecondChannel.getHeader(HEADER_LOCATION));
    // list channels
    /* @formatter:off */
    JsonPath listChannels = given().get("channels").getBody().jsonPath();
    /* @formatter:on */
    // TODO remove until delete channel is implemented
    // assertThat(listChannels, is(numberOfChannels(2)));
    assertThat(listChannels, containsChannel("channel-123"));
    assertThat(listChannels, containsChannel("channel-abc"));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Ignore(org.junit.Ignore) Test(org.junit.Test)

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