Search in sources :

Example 1 with Signatur

use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.

the class ArendeServiceTest method createQuestionInvalidCertificateTypeTest.

@Test
public void createQuestionInvalidCertificateTypeTest() {
    Utkast utkast = new Utkast();
    utkast.setSignatur(new Signatur());
    utkast.setIntygsTyp("fk7263");
    when(utkastRepository.findOne(anyString())).thenReturn(utkast);
    try {
        service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
        fail("should throw exception");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.INVALID_STATE, e.getErrorCode());
        verifyZeroInteractions(arendeRepository);
        verifyZeroInteractions(notificationService);
        verifyZeroInteractions(arendeDraftService);
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) Test(org.junit.Test)

Example 2 with Signatur

use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsCancelledFirst.

@Test
public void testConvertUtkastToListIntygEntrySetsCancelledFirst() {
    Signatur signatur = mock(Signatur.class);
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    utkast.setSignatur(signatur);
    utkast.setAterkalladDatum(LocalDateTime.now());
    utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
    when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(CertificateState.CANCELLED.name(), res.getStatus());
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

Example 3 with Signatur

use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameReturnsSignaturHsaId.

@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameReturnsSignaturHsaId() {
    Signatur signatur = mock(Signatur.class);
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    utkast.setSignatur(signatur);
    when(signatur.getSigneradAv()).thenReturn(utkast.getSenastSparadAv().getNamn());
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(utkast.getSenastSparadAv().getNamn(), res.getUpdatedSignedBy());
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

Example 4 with Signatur

use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.

the class IntygResource method updateUtkastForSend.

private void updateUtkastForSend(@PathParam("id") String id) {
    Utkast utkast = utkastRepository.findOne(id);
    if (utkast != null) {
        utkast.setStatus(UtkastStatus.SIGNED);
        Utlatande utlatande = moduleFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), utkast.getModel());
        utlatande.getGrundData().setSigneringsdatum(LocalDateTime.now());
        try {
            CustomObjectMapper mapper = new CustomObjectMapper();
            StringWriter writer = new StringWriter();
            mapper.writeValue(writer, utlatande);
            utkast.setModel(writer.toString());
        } catch (IOException e) {
            LOG.error("Could not update the model of the utkast. Failed with message ", e.getMessage());
        }
        if (utkast.getSignatur() == null) {
            Signatur sig = new Signatur(LocalDateTime.now(), "", id, "", "", "");
            utkast.setSignatur(sig);
        }
        utkast.setSkickadTillMottagare("FKASSA");
        utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
        utkastRepository.save(utkast);
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) StringWriter(java.io.StringWriter) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) CustomObjectMapper(se.inera.intyg.common.util.integration.json.CustomObjectMapper) IOException(java.io.IOException)

Example 5 with Signatur

use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.

the class IntygResource method updateUtkastForSign.

private void updateUtkastForSign(@PathParam("id") String id, String signeratAv) {
    Utkast utkast = utkastRepository.findOne(id);
    if (utkast != null) {
        utkast.setStatus(UtkastStatus.SIGNED);
        Signatur sig = new Signatur(LocalDateTime.now(), signeratAv != null ? signeratAv : "", id, "", "", "");
        utkast.setSignatur(sig);
        utkastRepository.save(utkast);
    }
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast)

Aggregations

Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)15 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)15 Test (org.junit.Test)8 ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)5 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)4 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 XPath (javax.xml.xpath.XPath)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 CustomObjectMapper (se.inera.intyg.common.util.integration.json.CustomObjectMapper)1 Feature (se.inera.intyg.infra.security.common.model.Feature)1 PagaendeSignering (se.inera.intyg.webcert.persistence.utkast.model.PagaendeSignering)1