Search in sources :

Example 6 with IntygServiceResult

use of se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult in project webcert by sklintyg.

the class IntygServiceSendTest method testSendIntygReturnsInfo.

@Test
public void testSendIntygReturnsInfo() throws Exception {
    final String completionMeddelandeId = "meddelandeId";
    SendCertificateToRecipientResponseType response = new SendCertificateToRecipientResponseType();
    response.setResult(ResultTypeUtil.infoResult("Info text"));
    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));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) Relation(se.inera.intyg.common.support.model.common.internal.Relation) WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) IntygServiceResult(se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 7 with IntygServiceResult

use of se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult in project webcert by sklintyg.

the class IntygServiceStoreTest method testStoreIntyg.

@Test
public void testStoreIntyg() throws Exception {
    IntygServiceResult res = intygService.storeIntyg(createUtkast());
    assertEquals(IntygServiceResult.OK, res);
    verify(certificateSenderService, times(1)).storeCertificate(INTYG_ID, INTYG_TYP_FK, json);
    verify(monitoringService).logIntygRegistered(INTYG_ID, INTYG_TYP_FK);
}
Also used : IntygServiceResult(se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult) Test(org.junit.Test)

Aggregations

IntygServiceResult (se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult)7 Test (org.junit.Test)5 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)4 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)3 Relation (se.inera.intyg.common.support.model.common.internal.Relation)3 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)3 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)3 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)3 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 SendCertificateToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType)1