Search in sources :

Example 11 with ListIntygEntry

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

the class IntygServiceTest method testListIntyg.

@Test
public void testListIntyg() {
    final String enhetsId = "enhet-1";
    // setup intygstjansten WS mock to return intyg information
    when(listCertificatesForCareResponder.listCertificatesForCare(eq(LOGICAL_ADDRESS), any(ListCertificatesForCareType.class))).thenReturn(listResponse);
    Pair<List<ListIntygEntry>, Boolean> intygItemListResponse = intygService.listIntyg(Collections.singletonList(enhetsId), PERSNR);
    ArgumentCaptor<ListCertificatesForCareType> argument = ArgumentCaptor.forClass(ListCertificatesForCareType.class);
    verify(listCertificatesForCareResponder).listCertificatesForCare(eq(LOGICAL_ADDRESS), argument.capture());
    assertEquals(2, intygItemListResponse.getLeft().size());
    ListIntygEntry meta = intygItemListResponse.getLeft().get(0);
    assertEquals("1", meta.getIntygId());
    assertEquals("fk7263", meta.getIntygType());
    assertEquals(CertificateState.SENT.name(), meta.getStatus());
    assertTrue(PERSNR.equals(meta.getPatientId()));
    assertEquals(1, argument.getValue().getEnhetsId().size());
    assertNotNull(argument.getValue().getEnhetsId().get(0).getRoot());
    assertEquals(enhetsId, argument.getValue().getEnhetsId().get(0).getExtension());
    assertNotNull(argument.getValue().getPersonId().getRoot());
    assertEquals("191212121212", argument.getValue().getPersonId().getExtension());
}
Also used : ListCertificatesForCareType(se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) ArrayList(java.util.ArrayList) List(java.util.List) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) Test(org.junit.Test)

Example 12 with ListIntygEntry

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

the class IntygRelationHelperImplTest method buildList.

private List<ListIntygEntry> buildList() {
    ListIntygEntry listIntygEntry = new ListIntygEntry();
    listIntygEntry.setIntygId(INTYG_ID);
    return Stream.of(listIntygEntry).collect(Collectors.toList());
}
Also used : ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)

Example 13 with ListIntygEntry

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

the class TestIntygFactory method createIntygItem.

public static ListIntygEntry createIntygItem(String id, LocalDateTime signedDate) {
    ListIntygEntry it = new ListIntygEntry();
    it.setIntygId(id);
    it.setUpdatedSignedBy("A Person");
    it.setLastUpdatedSigned(signedDate);
    it.setIntygType("Type 1");
    it.setStatus(CertificateState.SENT.name());
    return it;
}
Also used : ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)

Example 14 with ListIntygEntry

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

the class IntygApiControllerTest method testListIntygOfflineMode.

@Test
public void testListIntygOfflineMode() {
    Pair<List<ListIntygEntry>, Boolean> offlineIntygItemListResponse = Pair.of(TestIntygFactory.createListWithIntygItems(), true);
    // Mock call to Intygstjanst
    when(intygService.listIntyg(ENHET_IDS, PNR)).thenReturn(offlineIntygItemListResponse);
    Response response = intygCtrl.listDraftsAndIntygForPerson(PNR.getPersonnummer());
    @SuppressWarnings("unchecked") List<ListIntygEntry> res = (List<ListIntygEntry>) response.getEntity();
    assertNotNull(res);
    assertEquals(2, res.size());
    assertEquals("true", response.getHeaderString("offline_mode"));
}
Also used : Response(javax.ws.rs.core.Response) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) List(java.util.List) Test(org.junit.Test)

Example 15 with ListIntygEntry

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

the class IntygRelationHelperImplTest method testDecorate.

@Test
public void testDecorate() {
    when(listRelationsForCertificateResponderInterface.listRelationsForCertificate(isNull(), any(ListRelationsForCertificateType.class))).thenReturn(buildResponse());
    when(certificateRelationService.getRelations(INTYG_ID)).thenReturn(buildWebcertRelationsWithParent());
    List<ListIntygEntry> listIntygEntries = buildList();
    testee.decorateIntygListWithRelations(listIntygEntries);
    ListIntygEntry lie = listIntygEntries.get(0);
    assertFrontendRelationsIntygsIds(lie.getRelations().getLatestChildRelations(), OTHER_INTYG_ID_3, null, OTHER_INTYG_ID, OTHER_INTYG_ID_2);
    assertEquals(lie.getRelations().getParent().getIntygsId(), PARENT_INTYG_1);
}
Also used : ListRelationsForCertificateType(se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.ListRelationsForCertificateType) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

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