@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); }
@Override public void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList) { ListRelationsForCertificateResponseType response = getRelationsFromIntygstjanst(fullIntygItemList.stream() .map(ListIntygEntry::getIntygId) .collect(Collectors.toList())); if (response != null) { for (IntygRelations ir : response.getIntygRelation()) { for (ListIntygEntry lie : fullIntygItemList) { if (lie.getIntygId().equals(ir.getIntygsId().getExtension())) { lie.setRelations(new Relations()); for (Relation r : ir.getRelation()) { applyRelation(lie.getIntygId(), lie.getRelations(), r); } } } } } for (ListIntygEntry lie : fullIntygItemList) { Relations relations = certificateRelationService.getRelations(lie.getIntygId()); mergeRelations(lie.getRelations(), relations); } }
IntygRelationHelperImpl implements IntygRelationHelper { @Override public void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList) { ListRelationsForCertificateResponseType response = getRelationsFromIntygstjanst(fullIntygItemList.stream() .map(ListIntygEntry::getIntygId) .collect(Collectors.toList())); if (response != null) { for (IntygRelations ir : response.getIntygRelation()) { for (ListIntygEntry lie : fullIntygItemList) { if (lie.getIntygId().equals(ir.getIntygsId().getExtension())) { lie.setRelations(new Relations()); for (Relation r : ir.getRelation()) { applyRelation(lie.getIntygId(), lie.getRelations(), r); } } } } } for (ListIntygEntry lie : fullIntygItemList) { Relations relations = certificateRelationService.getRelations(lie.getIntygId()); mergeRelations(lie.getRelations(), relations); } } }
IntygRelationHelperImpl implements IntygRelationHelper { @Override public void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList) { ListRelationsForCertificateResponseType response = getRelationsFromIntygstjanst(fullIntygItemList.stream() .map(ListIntygEntry::getIntygId) .collect(Collectors.toList())); if (response != null) { for (IntygRelations ir : response.getIntygRelation()) { for (ListIntygEntry lie : fullIntygItemList) { if (lie.getIntygId().equals(ir.getIntygsId().getExtension())) { lie.setRelations(new Relations()); for (Relation r : ir.getRelation()) { applyRelation(lie.getIntygId(), lie.getRelations(), r); } } } } } for (ListIntygEntry lie : fullIntygItemList) { Relations relations = certificateRelationService.getRelations(lie.getIntygId()); mergeRelations(lie.getRelations(), relations); } }  }
IntygRelationHelperImpl implements IntygRelationHelper { @Override public void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList) { ListRelationsForCertificateResponseType response = getRelationsFromIntygstjanst(fullIntygItemList.stream() .map(ListIntygEntry::getIntygId) .collect(Collectors.toList())); if (response != null) { for (IntygRelations ir : response.getIntygRelation()) { for (ListIntygEntry lie : fullIntygItemList) { if (lie.getIntygId().equals(ir.getIntygsId().getExtension())) { lie.setRelations(new Relations()); for (Relation r : ir.getRelation()) { applyRelation(lie.getIntygId(), lie.getRelations(), r); } } } } } for (ListIntygEntry lie : fullIntygItemList) { Relations relations = certificateRelationService.getRelations(lie.getIntygId()); mergeRelations(lie.getRelations(), relations); } }  @Override Relations getRelationsForIntyg(String intygId); @Override void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList); }
IntygRelationHelperImpl implements IntygRelationHelper { @Override public void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList) { ListRelationsForCertificateResponseType response = getRelationsFromIntygstjanst(fullIntygItemList.stream() .map(ListIntygEntry::getIntygId) .collect(Collectors.toList())); if (response != null) { for (IntygRelations ir : response.getIntygRelation()) { for (ListIntygEntry lie : fullIntygItemList) { if (lie.getIntygId().equals(ir.getIntygsId().getExtension())) { lie.setRelations(new Relations()); for (Relation r : ir.getRelation()) { applyRelation(lie.getIntygId(), lie.getRelations(), r); } } } } } for (ListIntygEntry lie : fullIntygItemList) { Relations relations = certificateRelationService.getRelations(lie.getIntygId()); mergeRelations(lie.getRelations(), relations); } }  @Override Relations getRelationsForIntyg(String intygId); @Override void decorateIntygListWithRelations(List<ListIntygEntry> fullIntygItemList);  }