use of se.inera.intyg.common.support.modules.support.api.dto.PdfResponse 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.common.support.modules.support.api.dto.PdfResponse 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));
}
use of se.inera.intyg.common.support.modules.support.api.dto.PdfResponse in project webcert by sklintyg.
the class IntygModuleFacadeImpl method convertFromInternalToPdfDocument.
@Override
public IntygPdf convertFromInternalToPdfDocument(String intygType, String internalIntygJsonModel, List<Status> statuses, boolean isEmployer) throws IntygModuleFacadeException {
boolean isUtkast = isUtkast(statuses);
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi(intygType);
PdfResponse pdfResponse;
if (!isEmployer) {
pdfResponse = moduleApi.pdf(internalIntygJsonModel, statuses, ApplicationOrigin.WEBCERT, isUtkast);
} else {
pdfResponse = moduleApi.pdfEmployer(internalIntygJsonModel, statuses, ApplicationOrigin.WEBCERT, Collections.emptyList(), isUtkast);
}
return new IntygPdf(pdfResponse.getPdfData(), pdfResponse.getFilename());
} catch (ModuleException me) {
LOG.error("ModuleException occured when when generating PDF document from internal");
throw new IntygModuleFacadeException("ModuleException occured when generating PDF document from internal", me);
} catch (ModuleNotFoundException e) {
LOG.error("ModuleNotFoundException occured for intygstyp '{}' when generating PDF document from internal", intygType);
throw new IntygModuleFacadeException("ModuleNotFoundException occured when registering certificate", e);
}
}
Aggregations