Search in sources :

Example 1 with ChangeSelectedUnitRequest

use of se.inera.intyg.webcert.web.web.controller.api.dto.ChangeSelectedUnitRequest in project webcert by sklintyg.

the class UserApiControllerIT method testAndraValdEnhetMedOgiltigEnhetsId.

/**
 * Verify that trying to change vardEnhet to an invalid one gives an error response.
 */
@Test
public void testAndraValdEnhetMedOgiltigEnhetsId() {
    // Log in as user having medarbetaruppdrag at several vardenheter.
    FakeCredentials user = new FakeCredentials.FakeCredentialsBuilder("IFV1239877878-104B", "IFV1239877878-1042").legitimeradeYrkesgrupper(asList("Läkare")).build();
    RestAssured.sessionId = getAuthSession(user);
    // An improvement of this would be to call hsaStub rest api to add testa data as we want it to
    // avoid "magic" ids and the dependency to bootstrapped data?
    final String vardEnhetToChangeTo = "non-existing-vardenehet-id";
    ChangeSelectedUnitRequest changeRequest = new ChangeSelectedUnitRequest();
    changeRequest.setId(vardEnhetToChangeTo);
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().body(changeRequest).expect().statusCode(400).when().post("api/anvandare/andraenhet");
}
Also used : FakeCredentials(se.inera.intyg.webcert.web.auth.fake.FakeCredentials) ChangeSelectedUnitRequest(se.inera.intyg.webcert.web.web.controller.api.dto.ChangeSelectedUnitRequest) Test(org.junit.Test) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)

Example 2 with ChangeSelectedUnitRequest

use of se.inera.intyg.webcert.web.web.controller.api.dto.ChangeSelectedUnitRequest in project webcert by sklintyg.

the class UserApiControllerIT method testAndraValdEnhet.

@Test
public void testAndraValdEnhet() {
    // Log in as user having medarbetaruppdrag at several vardenheter.
    FakeCredentials user = new FakeCredentials.FakeCredentialsBuilder("IFV1239877878-104B", "IFV1239877878-1042").legitimeradeYrkesgrupper(asList("Läkare")).build();
    RestAssured.sessionId = getAuthSession(user);
    // An improvement of this would be to call hsaStub rest api to add testa data as we want it to
    // avoid "magic" ids and the dependency to bootstrapped data?
    final String vardEnhetToChangeTo = "IFV1239877878-1045";
    ChangeSelectedUnitRequest changeRequest = new ChangeSelectedUnitRequest();
    changeRequest.setId(vardEnhetToChangeTo);
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().body(changeRequest).when().post("api/anvandare/andraenhet").then().statusCode(200).body(matchesJsonSchemaInClasspath("jsonschema/webcert-user-response-schema.json")).body("valdVardenhet.id", equalTo(vardEnhetToChangeTo));
}
Also used : FakeCredentials(se.inera.intyg.webcert.web.auth.fake.FakeCredentials) ChangeSelectedUnitRequest(se.inera.intyg.webcert.web.web.controller.api.dto.ChangeSelectedUnitRequest) Test(org.junit.Test) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)

Aggregations

Test (org.junit.Test)2 FakeCredentials (se.inera.intyg.webcert.web.auth.fake.FakeCredentials)2 ChangeSelectedUnitRequest (se.inera.intyg.webcert.web.web.controller.api.dto.ChangeSelectedUnitRequest)2 BaseRestIntegrationTest (se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)2