use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class ArendeServiceTest method buildUserOfRole.
private WebCertUser buildUserOfRole(Role role) {
WebCertUser user = new WebCertUser();
user.setRoles(AuthoritiesResolverUtil.toMap(role));
user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
user.setOrigin(UserOriginType.NORMAL.name());
user.setHsaId("testuser");
user.setNamn("test userman");
Feature feature = new Feature();
feature.setName(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR);
feature.setGlobal(true);
feature.setIntygstyper(ImmutableList.of(INTYG_TYP));
user.setFeatures(ImmutableMap.of(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR, feature));
Vardenhet vardenhet = new Vardenhet(ENHET_ID, "enhet");
Vardgivare vardgivare = new Vardgivare("vardgivare", "Vardgivaren");
vardgivare.getVardenheter().add(vardenhet);
user.setVardgivare(Collections.singletonList(vardgivare));
user.setValdVardenhet(vardenhet);
return user;
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class ArendeServiceTest method answerUpdatesQuestionTest.
@Test
public void answerUpdatesQuestionTest() throws CertificateSenderException {
final String svarPaMeddelandeId = "svarPaMeddelandeId";
Arende fraga = buildArende(svarPaMeddelandeId, null);
fraga.setAmne(ArendeAmne.OVRIGT);
fraga.setMeddelandeId(svarPaMeddelandeId);
fraga.setStatus(Status.PENDING_INTERNAL_ACTION);
fraga.setPatientPersonId(PERSON_ID);
when(arendeRepository.findOneByMeddelandeId(svarPaMeddelandeId)).thenReturn(fraga);
when(webcertUserService.isAuthorizedForUnit(isNull(), anyBoolean())).thenReturn(true);
when(webcertUserService.getUser()).thenReturn(new WebCertUser());
ArendeConversationView result = service.answer(svarPaMeddelandeId, "svarstext");
assertNotNull(result.getFraga());
assertNotNull(result.getSvar());
assertEquals(FIXED_TIME_INSTANT, result.getSenasteHandelse().toInstant(ZoneId.systemDefault().getRules().getOffset(FIXED_TIME_INSTANT)));
verify(webcertUserService).isAuthorizedForUnit(isNull(), anyBoolean());
verify(monitoringLog).logArendeCreated(anyString(), anyString(), isNull(), any(ArendeAmne.class), anyBoolean());
verify(certificateSenderService).sendMessageToRecipient(anyString(), anyString());
verify(notificationService).sendNotificationForQAs(INTYG_ID, NotificationEvent.NEW_ANSWER_FROM_CARE);
ArgumentCaptor<Arende> arendeCaptor = ArgumentCaptor.forClass(Arende.class);
verify(arendeRepository, times(2)).save(arendeCaptor.capture());
verify(arendeDraftService).delete(INTYG_ID, svarPaMeddelandeId);
Arende updatedQuestion = arendeCaptor.getAllValues().get(1);
assertEquals(FIXED_TIME_INSTANT, updatedQuestion.getSenasteHandelse().toInstant(ZoneId.systemDefault().getRules().getOffset(FIXED_TIME_INSTANT)));
assertEquals(Status.CLOSED, updatedQuestion.getStatus());
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class BaseCreateDraftCertificateTest method buildWebCertUser.
protected WebCertUser buildWebCertUser() {
WebCertUser user = new WebCertUser();
user.setAuthorities(new HashMap<>());
user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, createPrivilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT));
user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, createPrivilege(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG));
// TODO
user.setFeatures(Stream.of(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST, AuthoritiesConstants.FEATURE_TAK_KONTROLL).collect(Collectors.toMap(Function.identity(), s -> {
Feature feature = new Feature();
feature.setName(s);
feature.setGlobal(true);
feature.setIntygstyper(Arrays.asList(FK7263, TSBAS));
return feature;
})));
user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
user.setBefattningar(Arrays.asList(TITLE_CODE));
user.setSpecialiseringar(Arrays.asList(ALLMAN_MEDICIN, INVARTES_MEDICIN));
user.setTitel(TITLE_NAME);
user.setVardgivare(Arrays.asList(createVardgivare()));
user.setMiuNamnPerEnhetsId(createMiuNamnPerEnhetsId());
return user;
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class BaseCreateDraftCertificateValidatorTest method buildUserUnauthorized.
protected WebCertUser buildUserUnauthorized() {
WebCertUser user = new WebCertUser();
user.setAuthorities(new HashMap<>());
user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, createPrivilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, ALL_INTYG_TYPES));
user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, createPrivilege(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, ALL_INTYG_TYPES));
Feature feature = new Feature();
feature.setName(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
feature.setIntygstyper(Arrays.asList(Fk7263EntryPoint.MODULE_ID, TsBasEntryPoint.MODULE_ID, TsDiabetesEntryPoint.MODULE_ID, LisjpEntryPoint.MODULE_ID, LuaenaEntryPoint.MODULE_ID, LuaefsEntryPoint.MODULE_ID, LuseEntryPoint.MODULE_ID, DbModuleEntryPoint.MODULE_ID, DoiModuleEntryPoint.MODULE_ID));
user.setFeatures(Collections.singletonMap(feature.getName(), feature));
user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
return user;
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class CreateDraftCertificateResponderImplTest method testCreateDraftCertificateNoMIUs.
@Test
public void testCreateDraftCertificateNoMIUs() {
WebCertUser userWithoutMiu = buildWebCertUser();
userWithoutMiu.setVardgivare(new ArrayList<>());
when(webcertUserDetailsService.loadUserByHsaId(USER_HSAID)).thenReturn(userWithoutMiu);
CreateDraftCertificateType certificateType = createCertificateType();
when(mockValidator.validate(any(Intyg.class))).thenReturn(new ResultValidator());
CreateDraftCertificateResponseType response = responder.createDraftCertificate(LOGICAL_ADDR, certificateType);
verify(mockMonitoringLogService).logMissingMedarbetarUppdrag(USER_HSAID, UNIT_HSAID);
assertNotNull(response);
assertEquals(response.getResult().getResultCode(), ResultCodeType.ERROR);
assertEquals(response.getResult().getErrorId(), ErrorIdType.VALIDATION_ERROR);
}
Aggregations