Search in sources :

Example 1 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry 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 2 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry 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 ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsUtkastStatusIfNoOtherAvailable.

@Test
public void testConvertUtkastToListIntygEntrySetsUtkastStatusIfNoOtherAvailable() {
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(createUtkast());
    assertNotNull(res);
    assertEquals(UtkastStatus.DRAFT_INCOMPLETE.name(), res.getStatus());
}
Also used : ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

Example 4 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry 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 5 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygDraftsConverterTest method assertOrder.

private void assertOrder(List<ListIntygEntry> res, String expectedOrder) {
    StringBuilder sb = new StringBuilder();
    for (ListIntygEntry entry : res) {
        sb.append(entry.getIntygId());
    }
    assertEquals(expectedOrder, sb.toString());
}
Also used : ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)

Aggregations

ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)26 Test (org.junit.Test)16 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)12 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)5 List (java.util.List)4 Response (javax.ws.rs.core.Response)3 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)3 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)2 ListCertificatesForCareType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType)2 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 OptimisticLockException (javax.persistence.OptimisticLockException)1 WebServiceException (javax.xml.ws.WebServiceException)1 ArgumentMatchers.anyBoolean (org.mockito.ArgumentMatchers.anyBoolean)1 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)1 IntygRelations (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)1