use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testCreateReplacementCopyFailedIfAlreadyReplacedBySignedIntyg.
@Test(expected = WebCertServiceException.class)
public void testCreateReplacementCopyFailedIfAlreadyReplacedBySignedIntyg() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", false, false, false, true));
when(userService.getUser()).thenReturn(user);
CopyUtkastBuilderResponse resp = createCopyUtkastBuilderResponse();
WebcertCertificateRelation ersattRelation = new WebcertCertificateRelation(INTYG_ID, RelationKod.ERSATT, LocalDateTime.now(), UtkastStatus.SIGNED);
when(certificateRelationService.getNewestRelationOfType(INTYG_ID, RelationKod.ERSATT, Arrays.asList(UtkastStatus.values()))).thenReturn(Optional.of(ersattRelation));
CreateReplacementCopyRequest copyReq = buildReplacementCopyRequest();
CreateReplacementCopyResponse copyResp = copyService.createReplacementCopy(copyReq);
assertNotNull(copyResp);
assertEquals(INTYG_COPY_ID, copyResp.getNewDraftIntygId());
assertEquals(INTYG_TYPE, copyResp.getNewDraftIntygType());
verify(mockPUService).getPerson(PATIENT_SSN);
verify(createReplacementUtkastBuilder).populateCopyUtkastFromSignedIntyg(any(CreateReplacementCopyRequest.class), any(Person.class), any(boolean.class), any(boolean.class), eq(true));
verify(mockUtkastRepository).save(any(Utkast.class));
verify(mockNotificationService).sendNotificationForDraftCreated(any(Utkast.class));
verify(userService).getUser();
verify(logService).logCreateIntyg(any(LogRequest.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 testCreateRenewalWhenIntegrated.
@Test
public void testCreateRenewalWhenIntegrated() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", false, false, false, true));
when(userService.getUser()).thenReturn(user);
when(mockUtkastRepository.exists(INTYG_ID)).thenReturn(Boolean.FALSE);
CopyUtkastBuilderResponse resp = createCopyUtkastBuilderResponse();
when(createRenewalCopyUtkastBuilder.populateCopyUtkastFromSignedIntyg(any(CreateRenewalCopyRequest.class), isNull(), eq(false), eq(false), eq(false))).thenReturn(resp);
CreateRenewalCopyRequest renewRequest = buildRenewalRequest();
renewRequest.setDjupintegrerad(true);
CreateRenewalCopyResponse renewalCopyResponse = copyService.createRenewalCopy(renewRequest);
assertNotNull(renewalCopyResponse);
assertEquals(INTYG_COPY_ID, renewalCopyResponse.getNewDraftIntygId());
assertEquals(INTYG_TYPE, renewalCopyResponse.getNewDraftIntygType());
verifyZeroInteractions(mockPUService);
verify(createRenewalCopyUtkastBuilder).populateCopyUtkastFromSignedIntyg(any(CreateRenewalCopyRequest.class), isNull(), eq(false), eq(false), eq(false));
verify(mockUtkastRepository).save(any(Utkast.class));
verify(referensService).saveReferens(eq(INTYG_COPY_ID), eq(reference));
verify(mockIntegreradeEnheterRegistry).addIfSameVardgivareButDifferentUnits(any(String.class), any(IntegreradEnhetEntry.class), anyString());
verify(mockNotificationService).sendNotificationForDraftCreated(any(Utkast.class));
verify(userService).getUser();
verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, false);
// Assert pdl log
verify(logService).logCreateIntyg(any(LogRequest.class));
}
use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testCreateCopyWhenIntegratedAndWithUpdatedSSN.
@Test
public void testCreateCopyWhenIntegratedAndWithUpdatedSSN() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", false, false, false, true));
when(userService.getUser()).thenReturn(user);
when(mockUtkastRepository.exists(INTYG_ID)).thenReturn(Boolean.FALSE);
CopyUtkastBuilderResponse resp = createCopyUtkastBuilderResponse();
when(createRenewalCopyUtkastBuilder.populateCopyUtkastFromSignedIntyg(any(CreateRenewalCopyRequest.class), isNull(), eq(false), eq(false), eq(false))).thenReturn(resp);
CreateRenewalCopyRequest copyReq = buildRenewalRequest();
copyReq.setNyttPatientPersonnummer(PATIENT_NEW_SSN);
copyReq.setDjupintegrerad(true);
CreateRenewalCopyResponse renewalCopyResponse = copyService.createRenewalCopy(copyReq);
assertNotNull(renewalCopyResponse);
assertEquals(INTYG_COPY_ID, renewalCopyResponse.getNewDraftIntygId());
assertEquals(INTYG_TYPE, renewalCopyResponse.getNewDraftIntygType());
verifyZeroInteractions(mockPUService);
verify(createRenewalCopyUtkastBuilder).populateCopyUtkastFromSignedIntyg(any(CreateRenewalCopyRequest.class), isNull(), eq(false), eq(false), eq(false));
verify(mockUtkastRepository).save(any(Utkast.class));
verify(mockIntegreradeEnheterRegistry).addIfSameVardgivareButDifferentUnits(any(String.class), any(IntegreradEnhetEntry.class), anyString());
verify(mockNotificationService).sendNotificationForDraftCreated(any(Utkast.class));
verify(userService).getUser();
verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, false);
// Assert pdl log
verify(logService).logCreateIntyg(any(LogRequest.class));
}
use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class IntygIntegrationControllerTest method invalidParametersShouldNotFailOnNullPatientInfo.
@Test
public void invalidParametersShouldNotFailOnNullPatientInfo() {
IntegrationParameters parameters = new IntegrationParameters(null, null, ALTERNATE_SSN, null, null, null, null, null, null, false, false, false, false);
WebCertUser user = createDefaultUser();
user.setParameters(parameters);
Response res = testee.handleRedirectToIntyg(uriInfo, INTYGSTYP, INTYGSID, ENHETSID, user);
assertEquals(Response.Status.TEMPORARY_REDIRECT.getStatusCode(), res.getStatus());
verify(authoritiesResolver).getFeatures(Arrays.asList(user.getValdVardenhet().getId(), user.getValdVardgivare().getId()));
}
use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters in project webcert by sklintyg.
the class IntygIntegrationControllerTest method referenceNotPersistedIfNotSupplied.
@Test
public void referenceNotPersistedIfNotSupplied() {
IntegrationParameters parameters = new IntegrationParameters(null, null, ALTERNATE_SSN, null, null, null, null, null, null, false, false, false, false);
WebCertUser user = createDefaultUser();
user.setParameters(parameters);
Response res = testee.handleRedirectToIntyg(uriInfo, INTYGSTYP, INTYGSID, ENHETSID, user);
assertEquals(Response.Status.TEMPORARY_REDIRECT.getStatusCode(), res.getStatus());
verify(referensService, times(0)).saveReferens(eq(INTYGSID), or(isNull(), any()));
}
Aggregations