use of se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest in project webcert by sklintyg.
the class UtkastApiControllerTest method testCreateUtkastFornamnTooLong.
@Test
public void testCreateUtkastFornamnTooLong() {
String intygsTyp = "luse";
setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
CreateUtkastRequest utkastRequest = buildRequest(intygsTyp);
utkastRequest.setPatientFornamn(Strings.repeat("a", 256));
Response response = utkastController.createUtkast(intygsTyp, utkastRequest);
assertEquals(BAD_REQUEST.getStatusCode(), response.getStatus());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest in project webcert by sklintyg.
the class BaseRestIntegrationTest method createUtkastRequest.
/**
* Create Utkast Request with default values for all but type and patient
*
* @param intygsType
* type to create
* @param patientPersonNummer
* patient to create it for
* @return a new CreateUtkastRequest
*/
protected CreateUtkastRequest createUtkastRequest(String intygsType, String patientPersonNummer) {
CreateUtkastRequest utkastRequest = new CreateUtkastRequest();
utkastRequest.setIntygType(intygsType);
utkastRequest.setPatientFornamn(DEFAULT_UTKAST_PATIENT_FORNAMN);
utkastRequest.setPatientEfternamn(DEFAULT_UTKAST_PATIENT_EFTERNAMN);
utkastRequest.setPatientPersonnummer(Personnummer.createPersonnummer(patientPersonNummer).get());
utkastRequest.setPatientPostadress("Blåbärsvägen 14");
utkastRequest.setPatientPostort("Molnet");
utkastRequest.setPatientPostnummer("44837");
return utkastRequest;
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest in project webcert by sklintyg.
the class BaseRestIntegrationTest method createUtkast.
/**
* Helper method to create an utkast of a given type for a given patient.
* The request will be made with the current auth session.
*
* @param intygsTyp
* Type to create
* @param patientPersonNummer
* the patient to create the utkast for
* @return Id for the new utkast
*/
protected String createUtkast(String intygsTyp, String patientPersonNummer) {
CreateUtkastRequest utkastRequest = createUtkastRequest(intygsTyp, patientPersonNummer);
Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).pathParam("intygstyp", intygsTyp).contentType(ContentType.JSON).body(utkastRequest).expect().statusCode(200).when().post("api/utkast/{intygstyp}").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-generic-utkast-response-schema.json")).body("intygsTyp", equalTo(utkastRequest.getIntygType())).extract().response();
// The type-specific model is a serialized json within the model property, need to extract that first.
JsonPath draft = new JsonPath(response.body().asString());
JsonPath model = new JsonPath(draft.getString("model"));
assertEquals(formatPersonnummer(patientPersonNummer), model.getString("grundData.patient.personId"));
final String utkastId = model.getString("id");
assertTrue(utkastId.length() > 0);
return utkastId;
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest in project webcert by sklintyg.
the class UtkastApiControllerIT method testCreateUtkast.
/**
* Generic method that created an utkast of given type and validates basic generic model properties
*
* @param utkastType
* The type of utkast to create
*/
private JsonPath testCreateUtkast(String utkastType) {
// Set up auth precondition
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
CreateUtkastRequest utkastRequest = createUtkastRequest(utkastType, DEFAULT_PATIENT_PERSONNUMMER);
Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(utkastRequest).expect().statusCode(200).when().post("api/utkast/" + utkastType).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-generic-utkast-response-schema.json")).body("intygsTyp", equalTo(utkastRequest.getIntygType())).body("skapadAv.hsaId", equalTo(DEFAULT_LAKARE.getHsaId())).body("enhetsId", equalTo(DEFAULT_LAKARE.getEnhetId())).body("version", equalTo(0)).body("skapadAv.namn", equalTo(DEFAULT_LAKARE_NAME)).body("patientFornamn", equalTo(utkastRequest.getPatientFornamn())).body("patientEfternamn", equalTo(utkastRequest.getPatientEfternamn())).extract().response();
// The type-specific model is a serialized json "within" the model property, need to extract that first and then
// we can assert some basic things.
JsonPath draft = new JsonPath(response.body().asString());
JsonPath model = new JsonPath(draft.getString("model"));
assertTrue(model.getString("id").length() > 0);
assertEquals(utkastRequest.getPatientPersonnummer().getPersonnummer(), model.getString("grundData.patient.personId"));
return model;
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CreateUtkastRequest in project webcert by sklintyg.
the class UtkastApiControllerIT method testCannotCreateUtkastOfDeprecatedType.
@Test
public void testCannotCreateUtkastOfDeprecatedType() {
String utkastType = "fk7263";
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
CreateUtkastRequest utkastRequest = createUtkastRequest(utkastType, DEFAULT_PATIENT_PERSONNUMMER);
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(utkastRequest).expect().statusCode(400).when().post("api/utkast/" + utkastType);
}
Aggregations