Search in sources :

Example 1 with PdfResponse

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));
}
Also used : Status(se.inera.intyg.common.support.model.Status) IntygPdf(se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf) PdfResponse(se.inera.intyg.common.support.modules.support.api.dto.PdfResponse) ApplicationOrigin(se.inera.intyg.common.support.modules.support.ApplicationOrigin) Test(org.junit.Test)

Example 2 with PdfResponse

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));
}
Also used : Status(se.inera.intyg.common.support.model.Status) IntygPdf(se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf) PdfResponse(se.inera.intyg.common.support.modules.support.api.dto.PdfResponse) ApplicationOrigin(se.inera.intyg.common.support.modules.support.ApplicationOrigin) Test(org.junit.Test)

Example 3 with PdfResponse

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);
    }
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) IntygPdf(se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) PdfResponse(se.inera.intyg.common.support.modules.support.api.dto.PdfResponse)

Aggregations

PdfResponse (se.inera.intyg.common.support.modules.support.api.dto.PdfResponse)3 IntygPdf (se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf)3 Test (org.junit.Test)2 Status (se.inera.intyg.common.support.model.Status)2 ApplicationOrigin (se.inera.intyg.common.support.modules.support.ApplicationOrigin)2 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)1