use of se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf in project webcert by sklintyg.
the class IntygServiceTest method testFetchIntygAsPdfFromIntygstjansten.
@SuppressWarnings("unchecked")
@Test
public void testFetchIntygAsPdfFromIntygstjansten() throws IOException, IntygModuleFacadeException {
when(utkastRepository.findOne(CERTIFICATE_ID)).thenReturn(null);
when(moduleFacade.convertFromInternalToPdfDocument(anyString(), anyString(), anyList(), anyBoolean())).thenReturn(buildPdfDocument());
IntygPdf intygPdf = intygService.fetchIntygAsPdf(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertNotNull(intygPdf);
verify(logservice).logPrintIntygAsPDF(any(LogRequest.class));
verify(utkastRepository, times(1)).findOne(anyString());
verify(moduleFacade, times(1)).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf in project webcert by sklintyg.
the class IntygServiceTest method testLoggingFetchIntygAsPdfWithDraft.
@SuppressWarnings("unchecked")
@Test
public void testLoggingFetchIntygAsPdfWithDraft() throws IOException, IntygModuleFacadeException {
final Utkast draft = getDraft(CERTIFICATE_ID);
when(utkastRepository.findOne(CERTIFICATE_ID)).thenReturn(draft);
Fk7263Utlatande utlatande = objectMapper.readValue(draft.getModel(), Fk7263Utlatande.class);
when(moduleFacade.getUtlatandeFromInternalModel(anyString(), anyString())).thenReturn(utlatande);
when(moduleFacade.convertFromInternalToPdfDocument(anyString(), anyString(), anyList(), anyBoolean())).thenReturn(buildPdfDocument());
IntygPdf intygPdf = intygService.fetchIntygAsPdf(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
assertNotNull(intygPdf);
verify(utkastRepository).findOne(anyString());
verify(logservice).logPrintIntygAsDraft(any(LogRequest.class));
verifyNoMoreInteractions(logservice);
verify(moduleFacade, times(0)).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf in project webcert by sklintyg.
the class IntygServiceImpl method fetchIntygAsPdf.
@Override
public IntygPdf fetchIntygAsPdf(String intygsId, String intygsTyp, boolean isEmployer) {
try {
LOG.debug("Fetching intyg '{}' as PDF", intygsId);
IntygContentHolder intyg = getIntygDataPreferWebcert(intygsId, intygsTyp);
//
verifyPuServiceAvailable(intyg);
boolean coherentJournaling = userIsDjupintegreradWithSjf();
if (!coherentJournaling) {
verifyEnhetsAuth(intyg.getUtlatande(), true);
}
IntygPdf intygPdf = modelFacade.convertFromInternalToPdfDocument(intygsTyp, intyg.getContents(), intyg.getStatuses(), isEmployer);
// Log print as PDF to PDL log
logPdfPrinting(intyg, coherentJournaling);
return intygPdf;
} catch (IntygModuleFacadeException e) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
}
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf in project webcert by sklintyg.
the class IntygModuleFacadeTest method testConvertFromInternalToPdfDocumentEmployer.
@SuppressWarnings("unchecked")
@Test
public void testConvertFromInternalToPdfDocumentEmployer() throws IntygModuleFacadeException, ModuleException {
byte[] pdfData = "PDFDATA".getBytes();
PdfResponse pdfResp = new PdfResponse(pdfData, "file.pdf");
when(moduleApi.pdfEmployer(anyString(), anyList(), any(ApplicationOrigin.class), anyList(), eq(false))).thenReturn(pdfResp);
IntygPdf intygPdf = moduleFacade.convertFromInternalToPdfDocument(CERTIFICATE_TYPE, INT_JSON, Arrays.asList(new Status(CertificateState.RECEIVED, "", LocalDateTime.now())), true);
assertNotNull(intygPdf.getPdfData());
assertEquals("file.pdf", intygPdf.getFilename());
verify(moduleApi).pdfEmployer(anyString(), anyList(), eq(ApplicationOrigin.WEBCERT), anyList(), eq(false));
}
use of se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf in project webcert by sklintyg.
the class IntygModuleFacadeTest method testConvertFromInternalToPdfDocument.
@SuppressWarnings("unchecked")
@Test
public void testConvertFromInternalToPdfDocument() throws IntygModuleFacadeException, ModuleException {
byte[] pdfData = "PDFDATA".getBytes();
PdfResponse pdfResp = new PdfResponse(pdfData, "file.pdf");
when(moduleApi.pdf(anyString(), anyList(), any(ApplicationOrigin.class), eq(false))).thenReturn(pdfResp);
IntygPdf intygPdf = moduleFacade.convertFromInternalToPdfDocument(CERTIFICATE_TYPE, INT_JSON, Arrays.asList(new Status(CertificateState.RECEIVED, "", LocalDateTime.now())), false);
assertNotNull(intygPdf.getPdfData());
assertEquals("file.pdf", intygPdf.getFilename());
verify(moduleApi).pdf(anyString(), anyList(), eq(ApplicationOrigin.WEBCERT), eq(false));
}
Aggregations