use of se.inera.intyg.common.support.model.common.internal.Relation in project webcert by sklintyg.
the class IntygServiceSendTest method testSendIntygFailsForReplacedCertificate.
@Test(expected = WebCertServiceException.class)
public void testSendIntygFailsForReplacedCertificate() 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(webCertUserService.isAuthorizedForUnit(anyString(), anyString(), anyBoolean())).thenReturn(true);
when(webCertUserService.getUser()).thenReturn(webCertUser);
when(intygRepository.findOne(INTYG_ID)).thenReturn(getUtkast(INTYG_ID));
WebcertCertificateRelation ersattRelation = new WebcertCertificateRelation(INTYG_ID, RelationKod.ERSATT, LocalDateTime.now(), UtkastStatus.SIGNED);
when(certificateRelationService.getNewestRelationOfType(eq(INTYG_ID), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.of(ersattRelation));
CertificateMetaData metaData = new CertificateMetaData();
metaData.setStatus(new ArrayList<>());
CertificateResponse revokedCertificateResponse = new CertificateResponse(json, utlatande, metaData, false);
when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(revokedCertificateResponse);
when(moduleFacade.getUtlatandeFromInternalModel(any(), any())).thenReturn(utlatande);
intygService.sendIntyg(INTYG_ID, INTYG_TYP_FK, "FKASSA", false);
verifyZeroInteractions(logService);
}
use of se.inera.intyg.common.support.model.common.internal.Relation in project webcert by sklintyg.
the class CreateRenewalCopyUtkastBuilder method createRelation.
private Relation createRelation(CreateRenewalCopyRequest request, RelationKod relationKod) {
Relation relation = new Relation();
relation.setRelationIntygsId(request.getOriginalIntygId());
relation.setRelationKod(relationKod);
return relation;
}
use of se.inera.intyg.common.support.model.common.internal.Relation in project webcert by sklintyg.
the class CopyCompletionUtkastBuilder method createRelation.
private Relation createRelation(CreateCompletionCopyRequest request, RelationKod relationKod) {
Relation relation = new Relation();
relation.setRelationIntygsId(request.getOriginalIntygId());
relation.setRelationKod(relationKod);
relation.setMeddelandeId(request.getMeddelandeId());
relation.setReferensId(getArendeReferensId(request.getMeddelandeId(), request.getTyp()));
return relation;
}
use of se.inera.intyg.common.support.model.common.internal.Relation 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));
}
use of se.inera.intyg.common.support.model.common.internal.Relation 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));
}
Aggregations