use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testCompletionContainsCommentStringInOvrigt.
@Test
public void testCompletionContainsCommentStringInOvrigt() throws Exception {
final String personnummer = "19121212-1212";
final String kommentar = "Testkommentar";
Personnummer pers = Personnummer.createPersonnummer(personnummer).get();
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
String intygsTyp = "lisjp";
String intygsId = createSignedIntyg(intygsTyp, personnummer);
createArendeQuestion(intygsTyp, intygsId, personnummer, ArendeAmne.KOMPLT);
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", intygsTyp);
pathParams.put("intygsId", intygsId);
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(pers);
copyIntygRequest.setKommentar(kommentar);
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}/komplettera").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(intygsId))).body("intygsTyp", equalTo(intygsTyp)).extract().response();
JsonPath intygJson = new JsonPath(response.body().asString());
String newUtkastId = intygJson.getString("intygsUtkastId");
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get("moduleapi/intyg/" + intygsTyp + "/" + newUtkastId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-get-intyg-response-schema.json")).body("contents.ovrigt", containsString(kommentar));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerTest method testReplaceIntygWithInvalidOrigin.
@Test(expected = AuthoritiesException.class)
public void testReplaceIntygWithInvalidOrigin() {
final String personnummer = "191212121212";
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
WebCertUser user = new WebCertUser();
addPrivileges(user, CERTIFICATE_TYPE, AuthoritiesConstants.PRIVILEGE_ERSATTA_INTYG);
user.setOrigin("UTHOPP");
when(webcertUserService.getUser()).thenReturn(user);
try {
moduleApiController.createReplacement(copyIntygRequest, CERTIFICATE_TYPE, CERTIFICATE_ID);
fail("Expected exception!");
} finally {
verifyZeroInteractions(copyUtkastService);
}
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerTest method testCreateRenewal.
@Test
public void testCreateRenewal() {
final String newDraftIntygId = "newDraftIntygId";
final String personnummer = "191212121212";
final String newPersonnummer = "201212121212";
final String efternamn = "efternamn";
final String fornamn = "fornamn";
final String mellannamn = "mellannamn";
final String postadress = "postadress";
final String postort = "postort";
final String postnummer = "postnummer";
CopyIntygRequest request = new CopyIntygRequest();
request.setPatientPersonnummer(createPnr(personnummer));
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(null, null, newPersonnummer, fornamn, mellannamn, efternamn, postadress, postnummer, postort, false, false, false, true));
addFeatures(user, CERTIFICATE_TYPE, AuthoritiesConstants.FEATURE_FORNYA_INTYG);
addPrivileges(user, CERTIFICATE_TYPE, AuthoritiesConstants.PRIVILEGE_FORNYA_INTYG);
user.setOrigin("NORMAL");
ArgumentCaptor<CreateRenewalCopyRequest> captor = ArgumentCaptor.forClass(CreateRenewalCopyRequest.class);
when(copyUtkastService.createRenewalCopy(captor.capture())).thenReturn(new CreateRenewalCopyResponse(CERTIFICATE_TYPE, newDraftIntygId, CERTIFICATE_ID));
when(webcertUserService.getUser()).thenReturn(user);
Response response = moduleApiController.createRenewal(request, CERTIFICATE_TYPE, CERTIFICATE_ID);
verify(copyUtkastService).createRenewalCopy(any());
verifyNoMoreInteractions(copyUtkastService);
assertEquals(newDraftIntygId, ((CopyIntygResponse) response.getEntity()).getIntygsUtkastId());
assertEquals(personnummer, captor.getValue().getPatient().getPersonId().getPersonnummer());
assertEquals(fornamn, captor.getValue().getPatient().getFornamn());
assertEquals(efternamn, captor.getValue().getPatient().getEfternamn());
assertEquals(mellannamn, captor.getValue().getPatient().getMellannamn());
assertEquals(postadress, captor.getValue().getPatient().getPostadress());
assertEquals(postnummer, captor.getValue().getPatient().getPostnummer());
assertEquals(postort, captor.getValue().getPatient().getPostort());
assertEquals(newPersonnummer, captor.getValue().getNyttPatientPersonnummer().getPersonnummer());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerTest method testReplaceIntygWithInvalidPriviledge.
@Test(expected = AuthoritiesException.class)
public void testReplaceIntygWithInvalidPriviledge() {
final String personnummer = "191212121212";
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
WebCertUser user = new WebCertUser();
user.setOrigin("NORMAL");
when(webcertUserService.getUser()).thenReturn(user);
try {
moduleApiController.createReplacement(copyIntygRequest, CERTIFICATE_TYPE, CERTIFICATE_ID);
fail("Expected exception!");
} finally {
verifyZeroInteractions(copyUtkastService);
}
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerTest method testCreateRenewalWithNewPatientInfo.
@Test
public void testCreateRenewalWithNewPatientInfo() {
final String personnummer = "191212121212";
final String newIntygId = "newIntygId";
final String efternamn = "efternamn";
final String fornamn = "fornamn";
final String mellannamn = "mellannamn";
final String postadress = "postadress";
final String postort = "postort";
final String postnummer = "postnummer";
final String newPersonnummer = "201212121212";
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(null, null, newPersonnummer, fornamn, mellannamn, efternamn, postadress, postnummer, postort, false, false, false, true));
addFeatures(user, CERTIFICATE_TYPE, AuthoritiesConstants.FEATURE_FORNYA_INTYG);
addPrivileges(user, CERTIFICATE_TYPE, AuthoritiesConstants.PRIVILEGE_FORNYA_INTYG);
user.setOrigin("NORMAL");
ArgumentCaptor<CreateRenewalCopyRequest> captor = ArgumentCaptor.forClass(CreateRenewalCopyRequest.class);
when(copyUtkastService.createRenewalCopy(captor.capture())).thenReturn(new CreateRenewalCopyResponse(CERTIFICATE_TYPE, newIntygId, CERTIFICATE_ID));
when(webcertUserService.getUser()).thenReturn(user);
Response response = moduleApiController.createRenewal(copyIntygRequest, CERTIFICATE_TYPE, CERTIFICATE_ID);
verify(copyUtkastService).createRenewalCopy(any());
verifyNoMoreInteractions(copyUtkastService);
assertEquals(newIntygId, ((CopyIntygResponse) response.getEntity()).getIntygsUtkastId());
assertEquals(personnummer, captor.getValue().getPatient().getPersonId().getPersonnummer());
assertEquals(fornamn, captor.getValue().getPatient().getFornamn());
assertEquals(efternamn, captor.getValue().getPatient().getEfternamn());
assertEquals(mellannamn, captor.getValue().getPatient().getMellannamn());
assertEquals(postadress, captor.getValue().getPatient().getPostadress());
assertEquals(postnummer, captor.getValue().getPatient().getPostnummer());
assertEquals(postort, captor.getValue().getPatient().getPostort());
assertEquals(newPersonnummer, captor.getValue().getNyttPatientPersonnummer().getPersonnummer());
}
Aggregations