use of se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testRenewalCopyFailIfSignedReplacementExists.
@Test(expected = WebCertServiceException.class)
public void testRenewalCopyFailIfSignedReplacementExists() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", false, false, false, true));
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 renewalCopyRequest = buildRenewalRequest();
try {
CreateRenewalCopyResponse copyResp = copyService.createRenewalCopy(renewalCopyRequest);
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.service.utkast.dto.CreateRenewalCopyRequest in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testCreateRenewalWhenIntegratedAndSjfTrue.
@Test
public void testCreateRenewalWhenIntegratedAndSjfTrue() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setOrigin(DJUPINTEGRATION.name());
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(createRenewalCopyUtkastBuilder.populateCopyUtkastFromOrignalUtkast(any(CreateRenewalCopyRequest.class), isNull(), any(boolean.class), eq(true), eq(false))).thenReturn(resp);
CreateRenewalCopyRequest copyReq = buildRenewalRequest();
copyReq.setDjupintegrerad(true);
CreateRenewalCopyResponse renewalResponse = copyService.createRenewalCopy(copyReq);
assertNotNull(renewalResponse);
assertEquals(INTYG_COPY_ID, renewalResponse.getNewDraftIntygId());
assertEquals(INTYG_TYPE, renewalResponse.getNewDraftIntygType());
assertEquals(INTYG_ID, renewalResponse.getOriginalIntygId());
verify(createRenewalCopyUtkastBuilder).populateCopyUtkastFromOrignalUtkast(any(CreateRenewalCopyRequest.class), isNull(), any(boolean.class), eq(true), eq(false));
verify(mockUtkastRepository).save(any(Utkast.class));
verify(mockNotificationService).sendNotificationForDraftCreated(any(Utkast.class));
verify(userService).getUser();
verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, true);
verify(mockIntegreradeEnheterRegistry).addIfSameVardgivareButDifferentUnits(any(String.class), any(IntegreradEnhetEntry.class), anyString());
}
use of se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testCreateRenewal.
@Test
public void testCreateRenewal() 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.TRUE);
CopyUtkastBuilderResponse resp = createCopyUtkastBuilderResponse();
when(createRenewalCopyUtkastBuilder.populateCopyUtkastFromOrignalUtkast(any(CreateRenewalCopyRequest.class), any(Person.class), any(boolean.class), any(boolean.class), eq(false))).thenReturn(resp);
when(certificateRelationService.getNewestRelationOfType(INTYG_ID, RelationKod.ERSATT, Arrays.asList(UtkastStatus.SIGNED))).thenReturn(Optional.empty());
CreateRenewalCopyRequest copyReq = buildRenewalRequest();
CreateRenewalCopyResponse renewalResponse = copyService.createRenewalCopy(copyReq);
assertNotNull(renewalResponse);
assertEquals(INTYG_COPY_ID, renewalResponse.getNewDraftIntygId());
assertEquals(INTYG_TYPE, renewalResponse.getNewDraftIntygType());
assertEquals(INTYG_ID, renewalResponse.getOriginalIntygId());
verify(mockPUService).getPerson(PATIENT_SSN);
verify(createRenewalCopyUtkastBuilder).populateCopyUtkastFromOrignalUtkast(any(CreateRenewalCopyRequest.class), any(Person.class), any(boolean.class), eq(false), 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.service.utkast.dto.CreateRenewalCopyRequest 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.service.utkast.dto.CreateRenewalCopyRequest 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));
}
Aggregations