use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class IntygServiceRevokeTest method setup.
@Before
public void setup() throws Exception {
HoSPersonal person = buildHosPerson();
VardpersonReferens vardperson = buildVardpersonReferens(person);
WebCertUser user = buildWebCertUser(person);
signedUtkast = buildUtkast(INTYG_ID, INTYG_TYPE, UtkastStatus.SIGNED, INTYG_JSON, vardperson);
revokedUtkast = buildUtkast(INTYG_ID, INTYG_TYPE, UtkastStatus.SIGNED, json, vardperson);
revokedUtkast.setAterkalladDatum(LocalDateTime.now());
when(webCertUserService.getUser()).thenReturn(user);
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class IntygServiceRevokeTest method buildWebCertUser.
private WebCertUser buildWebCertUser(HoSPersonal person) {
Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
WebCertUser user = new WebCertUser();
user.setRoles(AuthoritiesResolverUtil.toMap(role));
user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
user.setParameters(new IntegrationParameters(USER_REFERENCE, "", "", "", "", "", "", "", "", false, false, false, true));
user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
user.setNamn(person.getFullstandigtNamn());
user.setHsaId(person.getPersonId());
return user;
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class IntygServiceSendTest method testSendIntygThrowsExceptionForOldFk7263WithSekretessmarkeradPatient.
@Test(expected = WebCertServiceException.class)
public void testSendIntygThrowsExceptionForOldFk7263WithSekretessmarkeradPatient() throws Exception {
final String completionMeddelandeId = "meddelandeId";
intygService.setSekretessmarkeringStartDatum(LocalDateTime.now().plusMonths(1L));
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.TRUE);
when(webCertUserService.getUser()).thenReturn(webCertUser);
when(intygRepository.findOne(INTYG_ID)).thenReturn(getUtkast(INTYG_ID));
try {
intygService.sendIntyg(INTYG_ID, INTYG_TYP_FK, "FKASSA", false);
} catch (Exception e) {
verifyZeroInteractions(logService);
throw e;
}
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser 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.user.dto.WebCertUser 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);
}
Aggregations