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());
}
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());
}
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;
}
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"));
}
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);
}
Aggregations