use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerTest method testCreateUtkastFromTemplateInvalidPrivleges.
@Test(expected = AuthoritiesException.class)
public void testCreateUtkastFromTemplateInvalidPrivleges() {
WebCertUser user = new WebCertUser();
user.setOrigin("NORMAL");
when(webcertUserService.getUser()).thenReturn(user);
CopyIntygRequest copyRequest = new CopyIntygRequest();
copyRequest.setPatientPersonnummer(createPnr("191212121212"));
try {
moduleApiController.createUtkastFromTemplate(copyRequest, CERTIFICATE_TYPE, CERTIFICATE_ID, CERTIFICATE_TYPE);
} finally {
verifyZeroInteractions(copyUtkastService);
}
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerTest method testReplaceIntyg.
@Test
public void testReplaceIntyg() {
final String personnummer = "191212121212";
final String newIntygId = "newIntygId";
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
WebCertUser user = new WebCertUser();
addFeatures(user, CERTIFICATE_TYPE, AuthoritiesConstants.FEATURE_FORNYA_INTYG);
addPrivileges(user, CERTIFICATE_TYPE, AuthoritiesConstants.PRIVILEGE_ERSATTA_INTYG);
user.setOrigin("NORMAL");
ArgumentCaptor<CreateReplacementCopyRequest> captor = ArgumentCaptor.forClass(CreateReplacementCopyRequest.class);
when(copyUtkastService.createReplacementCopy(captor.capture())).thenReturn(new CreateReplacementCopyResponse(CERTIFICATE_TYPE, newIntygId, CERTIFICATE_ID));
when(webcertUserService.getUser()).thenReturn(user);
Response response = moduleApiController.createReplacement(copyIntygRequest, CERTIFICATE_TYPE, CERTIFICATE_ID);
verify(copyUtkastService).createReplacementCopy(any());
verifyNoMoreInteractions(copyUtkastService);
assertEquals(newIntygId, ((CopyIntygResponse) response.getEntity()).getIntygsUtkastId());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testReplaceIntyg.
@Test
public void testReplaceIntyg() {
final String personnummer = "19121212-1212";
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
changeOriginTo("DJUPINTEGRATION");
String intygsId = createSignedIntyg("lisjp", personnummer);
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", "lisjp");
pathParams.put("intygsId", intygsId);
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}/ersatt").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(intygsId))).body("intygsTyp", equalTo("lisjp")).extract().response();
JsonPath intygJson = new JsonPath(response.body().asString());
String utkastId = intygJson.getString("intygsUtkastId");
// Verify that the new draft has correct relations
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/lisjp/" + utkastId).then().body("relations.parent.intygsId", equalTo(intygsId)).body("relations.parent.relationKod", equalTo(RelationKod.ERSATT.name()));
// Verify the original certficate has a child relationship
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get("moduleapi/intyg/lisjp/" + intygsId).then().body("relations.latestChildRelations.replacedByUtkast.intygsId", equalTo(utkastId)).body("relations.latestChildRelations.replacedByUtkast.relationKod", equalTo(RelationKod.ERSATT.name()));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testCreateUtkastFromTemplate.
@Test
public void testCreateUtkastFromTemplate() throws Exception {
final String personnummer = "19121212-1212";
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
String dbIntyg = createDbIntyg(personnummer);
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", "db");
pathParams.put("intygsId", dbIntyg);
pathParams.put("newIntygsTyp", "doi");
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(200).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/{newIntygsTyp}/create").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(dbIntyg))).body("intygsTyp", equalTo("doi"));
}
Aggregations