use of se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult in project webcert by sklintyg.
the class IntygModuleApiController method revokeSignedIntyg.
/**
* Issues a request to Intygstjanst to revoke the signed intyg.
*
* @param intygsId The id of the intyg to revoke
* @param param A JSON struct containing an optional message
*/
@POST
@Path("/{intygsTyp}/{intygsId}/aterkalla")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response revokeSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) {
validateRevokeAuthority(intygsTyp);
if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) {
LOG.warn("Request to revoke '{}' is not valid", intygsId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload");
}
IntygServiceResult result = revokeIntyg(intygsTyp, intygsId, param);
return Response.ok(result).build();
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult in project webcert by sklintyg.
the class IntygModuleApiController method sendSignedIntyg.
/**
* Issues a request to Intygstjanst to send the signed intyg to a recipient.
*/
@POST
@Path("/{intygsTyp}/{intygsId}/skicka")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response sendSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, SendSignedIntygParameter param) {
authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_SKICKA_INTYG).orThrow();
IntygServiceResult sendResult = intygService.sendIntyg(intygsId, intygsTyp, param.getRecipient(), false);
return Response.ok(sendResult).build();
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult in project webcert by sklintyg.
the class IntygServiceRevokeTest method testRevokeIntyg.
@Test
public void testRevokeIntyg() throws Exception {
when(intygRepository.findOne(INTYG_ID)).thenReturn(signedUtkast);
// do the call
IntygServiceResult res = intygService.revokeIntyg(INTYG_ID, INTYG_TYP_FK, REVOKE_MSG, REVOKE_REASON);
// verify that services were called
verify(arendeService).closeAllNonClosed(INTYG_ID);
verify(notificationService, times(1)).sendNotificationForIntygRevoked(INTYG_ID);
verify(logService).logRevokeIntyg(any(LogRequest.class));
verify(intygRepository).save(any(Utkast.class));
verify(certificateSenderService, times(1)).revokeCertificate(eq(INTYG_ID), any(), eq(INTYG_TYP_FK));
verify(moduleFacade, times(1)).getRevokeCertificateRequest(eq(INTYG_TYP_FK), any(), any(), eq(REVOKE_MSG));
verify(monitoringService).logIntygRevoked(INTYG_ID, HSA_ID, REVOKE_REASON);
assertEquals(IntygServiceResult.OK, res);
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult in project webcert by sklintyg.
the class IntygServiceSendTest method testSendIntyg.
@Test
public void testSendIntyg() throws Exception {
final String completionMeddelandeId = "meddelandeId";
WebCertUser webCertUser = createUser();
Utlatande completionUtlatande = utlatande;
completionUtlatande.getGrundData().setRelation(new Relation());
completionUtlatande.getGrundData().getRelation().setRelationKod(RelationKod.KOMPLT);
completionUtlatande.getGrundData().getRelation().setMeddelandeId(completionMeddelandeId);
when(moduleFacade.getUtlatandeFromInternalModel(isNull(), anyString())).thenReturn(completionUtlatande);
when(webCertUserService.isAuthorizedForUnit(anyString(), anyString(), anyBoolean())).thenReturn(true);
when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.FALSE);
when(webCertUserService.getUser()).thenReturn(webCertUser);
when(intygRepository.findOne(INTYG_ID)).thenReturn(getUtkast(INTYG_ID));
IntygServiceResult res = intygService.sendIntyg(INTYG_ID, INTYG_TYP_FK, "FKASSA", false);
assertEquals(IntygServiceResult.OK, res);
verify(logService).logSendIntygToRecipient(any(LogRequest.class));
verify(certificateSenderService).sendCertificate(anyString(), any(Personnummer.class), anyString(), anyString(), eq(false));
verify(intygRepository, times(2)).findOne(INTYG_ID);
verify(intygRepository).save(any(Utkast.class));
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult in project webcert by sklintyg.
the class IntygServiceSendTest method testSendIntygCompletion.
@Test
public void testSendIntygCompletion() throws Exception {
final String completionMeddelandeId = "meddelandeId";
WebCertUser webCertUser = createUser();
when(webCertUserService.isAuthorizedForUnit(anyString(), anyString(), anyBoolean())).thenReturn(true);
when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.FALSE);
when(webCertUserService.getUser()).thenReturn(webCertUser);
when(intygRepository.findOne(INTYG_ID)).thenReturn(getUtkast(INTYG_ID));
Utlatande completionUtlatande = utlatande;
completionUtlatande.getGrundData().setRelation(new Relation());
completionUtlatande.getGrundData().getRelation().setRelationKod(RelationKod.KOMPLT);
completionUtlatande.getGrundData().getRelation().setMeddelandeId(completionMeddelandeId);
when(moduleFacade.getUtlatandeFromInternalModel(isNull(), anyString())).thenReturn(completionUtlatande);
when(certificateRelationService.getNewestRelationOfType(eq(INTYG_ID), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.empty());
IntygServiceResult res = intygService.sendIntyg(INTYG_ID, INTYG_TYP_FK, "FKASSA", false);
assertEquals(IntygServiceResult.OK, res);
verify(logService).logSendIntygToRecipient(any(LogRequest.class));
verify(certificateSenderService).sendCertificate(anyString(), any(Personnummer.class), anyString(), anyString(), eq(false));
verify(intygRepository, times(2)).findOne(INTYG_ID);
verify(intygRepository).save(any(Utkast.class));
}
Aggregations