Search in sources :

Example 1 with IntygPdf

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);
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) IntygPdf(se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf) Test(org.junit.Test)

Example 2 with IntygPdf

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);
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) IntygPdf(se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf) Test(org.junit.Test)

Example 3 with IntygPdf

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);
    }
}
Also used : IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) IntygPdf(se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf) IntygModuleFacadeException(se.inera.intyg.webcert.web.service.intyg.converter.IntygModuleFacadeException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 4 with IntygPdf

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));
}
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 5 with IntygPdf

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));
}
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)

Aggregations

IntygPdf (se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf)10 Test (org.junit.Test)8 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)4 PdfResponse (se.inera.intyg.common.support.modules.support.api.dto.PdfResponse)3 Response (javax.ws.rs.core.Response)2 Status (se.inera.intyg.common.support.model.Status)2 ApplicationOrigin (se.inera.intyg.common.support.modules.support.ApplicationOrigin)2 CreateCompletionCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse)2 CreateRenewalCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse)2 CreateReplacementCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateReplacementCopyResponse)2 CreateUtkastFromTemplateResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateResponse)2 CopyIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse)2 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)1 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 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1 IntygModuleFacadeException (se.inera.intyg.webcert.web.service.intyg.converter.IntygModuleFacadeException)1 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)1