use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class UtkastModuleApiControllerTest method setupUser.
private void setupUser(String privilegeString, String intygType, boolean coherentJournaling, String... features) {
WebCertUser user = new WebCertUser();
user.setAuthorities(new HashMap<>());
user.setFeatures(Stream.of(features).collect(Collectors.toMap(Function.identity(), s -> {
Feature feature = new Feature();
feature.setName(s);
feature.setIntygstyper(Arrays.asList(intygType));
return feature;
})));
user.setParameters(new IntegrationParameters("", "", "", "", "", "", "", "", "", coherentJournaling, false, false, true));
Privilege privilege = new Privilege();
privilege.setIntygstyper(Arrays.asList(intygType));
RequestOrigin requestOrigin = new RequestOrigin();
requestOrigin.setName("NORMAL");
requestOrigin.setIntygstyper(privilege.getIntygstyper());
privilege.setRequestOrigins(Arrays.asList(requestOrigin));
user.getAuthorities().put(privilegeString, privilege);
user.setOrigin("NORMAL");
when(webcertUserService.getUser()).thenReturn(user);
}
use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testCreateCompletion.
@Test
public void testCreateCompletion() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", true, false, false, true));
when(userService.getUser()).thenReturn(user);
when(mockUtkastRepository.exists(INTYG_ID)).thenReturn(Boolean.TRUE);
CopyUtkastBuilderResponse resp = createCopyUtkastBuilderResponse();
when(copyCompletionUtkastBuilder.populateCopyUtkastFromOrignalUtkast(any(CreateCompletionCopyRequest.class), any(Person.class), any(boolean.class), any(boolean.class), eq(false))).thenReturn(resp);
CreateCompletionCopyRequest copyReq = buildCompletionRequest();
CreateCompletionCopyResponse copyResp = copyService.createCompletion(copyReq);
assertNotNull(copyResp);
assertEquals(INTYG_COPY_ID, copyResp.getNewDraftIntygId());
assertEquals(INTYG_TYPE, copyResp.getNewDraftIntygType());
assertEquals(INTYG_ID, copyResp.getOriginalIntygId());
verify(mockPUService).getPerson(PATIENT_SSN);
verify(copyCompletionUtkastBuilder).populateCopyUtkastFromOrignalUtkast(any(CreateCompletionCopyRequest.class), any(Person.class), any(boolean.class), any(boolean.class), eq(false));
verify(mockUtkastRepository).save(any(Utkast.class));
verify(referensService).saveReferens(eq(INTYG_COPY_ID), eq(reference));
verify(mockNotificationService).sendNotificationForDraftCreated(any(Utkast.class));
verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, false);
}
use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testCreateRenewalFailsWhenReplacedBySignedIntyg.
@Test(expected = WebCertServiceException.class)
public void testCreateRenewalFailsWhenReplacedBySignedIntyg() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", false, false, false, true));
when(userService.getUser()).thenReturn(user);
WebcertCertificateRelation ersattRelation = new WebcertCertificateRelation(INTYG_ID, RelationKod.ERSATT, LocalDateTime.now(), UtkastStatus.SIGNED);
when(certificateRelationService.getNewestRelationOfType(INTYG_ID, RelationKod.ERSATT, Arrays.asList(UtkastStatus.SIGNED))).thenReturn(Optional.of(ersattRelation));
CreateRenewalCopyRequest copyReq = buildRenewalRequest();
try {
copyService.createRenewalCopy(copyReq);
fail("An exception should have been thrown.");
} catch (Exception e) {
verifyZeroInteractions(mockUtkastRepository);
verifyZeroInteractions(mockNotificationService);
verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, false);
// Assert no pdl logging
verifyZeroInteractions(logService);
throw e;
}
}
use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class UtkastServiceImplTest method createUser.
private WebCertUser createUser() {
Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
WebCertUser user = new WebCertUser();
user.setRoles(AuthoritiesResolverUtil.toMap(role));
user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
user.setHsaId("hsaId");
user.setNamn("namn");
List<String> tmp = new ArrayList<>();
tmp.add("Ortoped");
user.setSpecialiseringar(tmp);
user.setTitel("Befattning");
Vardgivare vardgivare = new Vardgivare();
vardgivare.setId("vardgivarid");
vardgivare.setNamn("vardgivarnamn");
user.setValdVardgivare(vardgivare);
Vardenhet vardenhet = new Vardenhet();
vardenhet.setId(UTKAST_ENHETS_ID);
vardenhet.setNamn("enhetnamn");
user.setValdVardenhet(vardenhet);
vardgivare.setVardenheter(Arrays.asList(vardenhet));
user.setVardgivare(Arrays.asList(vardgivare));
user.setParameters(new IntegrationParameters(USER_REFERENCE, "", "", "", "", "", "", "", "", false, false, false, true));
return user;
}
use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class IntygIntegrationServiceImplTest method verifyMonitoringWhenSammanhallenSjukforingAndOtherVardenhet.
@Test
public void verifyMonitoringWhenSammanhallenSjukforingAndOtherVardenhet() {
// given
when(utkastRepository.findOne(anyString())).thenReturn(createUtkast());
when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.FALSE);
IntegrationParameters parameters = new IntegrationParameters(null, null, ALTERNATE_SSN, "Nollan", null, "Nollansson", "Nollgatan", "000000", "Nollby", true, false, false, false);
WebCertUser user = createDefaultUser();
user.setParameters(parameters);
user.setValdVardgivare(createVardenhet());
// when
testee.prepareRedirectToIntyg(INTYGSTYP, INTYGSID, user);
// then
verify(monitoringLog).logIntegratedOtherCaregiver(anyString(), anyString(), anyString(), anyString());
}
Aggregations