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");
}
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));
}
Aggregations