Search in sources :

Example 11 with Signatur

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

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameFromSkapadAv.

@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameFromSkapadAv() {
    Signatur signatur = mock(Signatur.class);
    final String skapadAvName = "Bengt Bengtsson";
    final String skapadAvHsaId = "BengtsHsaId";
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    utkast.getSkapadAv().setNamn(skapadAvName);
    utkast.setSignatur(signatur);
    when(signatur.getSigneradAv()).thenReturn(skapadAvHsaId);
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(skapadAvHsaId, 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 12 with Signatur

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

the class IntygDraftsConverterTest method createUtkast.

private Utkast createUtkast() {
    final String sparadAvNamn = "namn efternamn";
    final String sparadAvHsaId = "hsaid";
    final String skapadAvHsaId = "hsaid";
    VardpersonReferens vardpersonReferens = new VardpersonReferens();
    Utkast utkast = new Utkast();
    utkast.setStatus(UtkastStatus.DRAFT_INCOMPLETE);
    utkast.setSenastSparadAv(vardpersonReferens);
    utkast.getSenastSparadAv().setNamn(sparadAvNamn);
    utkast.getSenastSparadAv().setHsaId(sparadAvHsaId);
    utkast.setSkapadAv(vardpersonReferens);
    utkast.getSkapadAv().setHsaId(skapadAvHsaId);
    utkast.setPatientPersonnummer(Personnummer.createPersonnummer("20121212-1211").get());
    Signatur signatur = mock(Signatur.class);
    utkast.setSignatur(signatur);
    when(signatur.getSigneradAv()).thenReturn(sparadAvHsaId);
    return utkast;
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)

Example 13 with Signatur

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

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsStatusReceivedIfApplicable.

@Test
public void testConvertUtkastToListIntygEntrySetsStatusReceivedIfApplicable() {
    Signatur signatur = mock(Signatur.class);
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    utkast.setSignatur(signatur);
    when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(CertificateState.RECEIVED.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 14 with Signatur

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

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsSentBeforeReceived.

@Test
public void testConvertUtkastToListIntygEntrySetsSentBeforeReceived() {
    Signatur signatur = mock(Signatur.class);
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    utkast.setSignatur(signatur);
    utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
    when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(CertificateState.SENT.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 15 with Signatur

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

the class ArendeServiceTest method createQuestionUnauthorizedTest.

@Test
public void createQuestionUnauthorizedTest() {
    Utkast utkast = new Utkast();
    utkast.setSignatur(new Signatur());
    when(utkastRepository.findOne(anyString())).thenReturn(utkast);
    try {
        service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
        fail("should throw exception");
    } catch (WebCertServiceException e) {
        assertEquals(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM, 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)

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