Search in sources :

Example 21 with Utkast

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

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsStatusSentIfApplicable.

@Test
public void testConvertUtkastToListIntygEntrySetsStatusSentIfApplicable() {
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(CertificateState.SENT.name(), res.getStatus());
}
Also used : 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 22 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast 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 23 with Utkast

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

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameNoSignatur.

@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameNoSignatur() {
    final String senastSparadAvName = "Anders Andersson";
    Utkast utkast = createUtkast();
    utkast.getSenastSparadAv().setNamn(senastSparadAvName);
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(senastSparadAvName, res.getUpdatedSignedBy());
}
Also used : 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 24 with Utkast

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

the class IntygDraftsConverterTest method testConvertIntygToListEntries.

@Test
public void testConvertIntygToListEntries() {
    LocalDateTime modfied = LocalDateTime.parse("2014-01-01T10:00:00");
    String id = "123";
    String type = "type";
    String updatedSignedBy = "Dr Dengroth";
    String updatedSignedByHsaId = "HSA1234";
    Personnummer patientId = Personnummer.createPersonnummer("19121212-1212").get();
    List<Utkast> utkastList = Collections.singletonList(TestIntygFactory.createUtkast(id, modfied, type, updatedSignedBy, updatedSignedByHsaId, UtkastStatus.DRAFT_COMPLETE, patientId));
    List<ListIntygEntry> res = IntygDraftsConverter.convertUtkastsToListIntygEntries(utkastList);
    assertNotNull(res);
    assertEquals(1, res.size());
    ListIntygEntry ref = res.get(0);
    assertEquals(id, ref.getIntygId());
    assertEquals(type, ref.getIntygType());
    assertEquals("DRAFT_COMPLETE", ref.getStatus());
    assertEquals(updatedSignedBy, ref.getUpdatedSignedBy());
    assertEquals(modfied, ref.getLastUpdatedSigned());
}
Also used : LocalDateTime(java.time.LocalDateTime) Personnummer(se.inera.intyg.schemas.contract.Personnummer) 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 25 with Utkast

use of se.inera.intyg.webcert.persistence.utkast.model.Utkast 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)

Aggregations

Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)171 Test (org.junit.Test)88 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)34 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)24 Personnummer (se.inera.intyg.schemas.contract.Personnummer)21 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)21 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)21 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)18 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)17 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)16 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)14 CreateNewDraftRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest)13 Patient (se.inera.intyg.common.support.model.common.internal.Patient)12 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)12 ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)12 Transactional (org.springframework.transaction.annotation.Transactional)11 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)11 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)11 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)10 ArrayList (java.util.ArrayList)9