AdapterComponentDocRepositoryHelper { String extractPatientInfo(List<SlotType1> documentSlots, String patientInfoName) { String slotValue = null; for (SlotType1 slot : documentSlots) { if (slot != null && slot.getName().equals(DocRepoConstants.XDS_SOURCE_PATIENT_INFO_SLOT) && slot.getValueList() != null && slot.getValueList().getValue() != null) { Iterator<String> iter = slot.getValueList().getValue().iterator(); while (iter.hasNext()) { String nextSlotValue = iter.next(); if (nextSlotValue.startsWith(patientInfoName)) { slotValue = nextSlotValue.substring(patientInfoName.length() + 1); LOG.debug("{} extractionValue: {}", patientInfoName, slotValue); } } } } return slotValue; }    }
@Test public void testExtractPatientInfo() { final String PATIENT_NAME = "John Doe"; final String SLOT_PATIENT_NAME = "John Doe <Patient Information>"; final String EXPECTED_RESULT = "<Patient Information>"; List<SlotType1> documentSlots = new ArrayList<>(); SlotType1 slot = mock(SlotType1.class); documentSlots.add(slot); ValueListType valueListType = mock(ValueListType.class); List<String> valueList = new ArrayList<>(); valueList.add(SLOT_PATIENT_NAME); when(slot.getName()).thenReturn(DocRepoConstants.XDS_SOURCE_PATIENT_INFO_SLOT); when(slot.getValueList()).thenReturn(valueListType); when(valueListType.getValue()).thenReturn(valueList); AdapterComponentDocRepositoryHelper docRepoHelper = new AdapterComponentDocRepositoryHelper(); String result = docRepoHelper.extractPatientInfo(documentSlots, PATIENT_NAME); assertEquals(result, EXPECTED_RESULT); }