AdapterComponentDocRepositoryOrchImpl { protected void extractEventCodes(DocumentMetadata doc, List<ClassificationType> classifications) { LOG.trace("Begin extractEventCodes"); HashSet<EventCode> eventCodes = new HashSet<>(); for (ClassificationType classification : classifications) { String classificationSchemeName = classification.getClassificationScheme(); if (DocRepoConstants.XDS_EVENT_CODE_LIST_CLASSIFICATION.equals(classificationSchemeName)) { LOG.debug("Found event code classification entry. Event code: {}", classification.getNodeRepresentation()); EventCode eventCode = new EventCode(); eventCode.setDocument(doc); eventCode.setEventCode(classification.getNodeRepresentation()); eventCode.setEventCodeScheme(docRepoHelper.extractMetadataFromSlots(classification.getSlot(), DocRepoConstants.XDS_CODING_SCHEME_SLOT, 0)); eventCode.setEventCodeDisplayName(classification.getName().getLocalizedString().get(0).getValue()); eventCodes.add(eventCode); } } doc.setEventCodes(eventCodes); LOG.trace("End extractEventCodes"); } AdapterComponentDocRepositoryOrchImpl(); DocumentService getDocumentService(); LargeFileUtils getLargeFileUtils(); UTCDateUtil getDateUtil(); RetrieveDocumentSetResponseType documentRepositoryRetrieveDocumentSet(RetrieveDocumentSetRequestType body); RegistryResponseType registerDocumentSet(RegisterDocumentSetRequestType body); RegistryResponseType documentRepositoryProvideAndRegisterDocumentSet(
        ProvideAndRegisterDocumentSetRequestType body); DocumentMetadata saveExtrinsicObject(ExtrinsicObjectType extrinsicObject, RegistryErrorList errorList,
        Map<String, DataHandler> docMap, boolean hasReplacementRequest);  }
@Test public void testExtractEventCodes() { final AdapterComponentDocRepositoryHelper docRepoHelper = mock(AdapterComponentDocRepositoryHelper.class); AdapterComponentDocRepositoryOrchImpl docRepo = new AdapterComponentDocRepositoryOrchImpl() { @Override protected AdapterComponentDocRepositoryHelper getHelper() { return docRepoHelper; } }; List<ClassificationType> classifications = new ArrayList<>(); ClassificationType classificationType = mock(ClassificationType.class); classifications.add(classificationType); SlotType1 slot = mock(SlotType1.class); List<SlotType1> slotList = new ArrayList<SlotType1>(); slotList.add(slot); final String EVENT_SCHEME = "event scheme"; final String NODE_REP = "node rep"; final String EVENT_CODE_DISPLAY_NAME = "event display name"; InternationalStringType internationalString = mock(InternationalStringType.class); LocalizedStringType localizedString = new LocalizedStringType(); localizedString.setValue(EVENT_CODE_DISPLAY_NAME); List<LocalizedStringType> eventCodeDisplayNameList = new ArrayList<>(); eventCodeDisplayNameList.add(localizedString); DocumentMetadata doc = new DocumentMetadata(); when(classificationType.getClassificationScheme()) .thenReturn(DocRepoConstants.XDS_EVENT_CODE_LIST_CLASSIFICATION); when(classificationType.getSlot()).thenReturn(slotList); when(classificationType.getNodeRepresentation()).thenReturn(NODE_REP); when(docRepoHelper.extractMetadataFromSlots(slotList, DocRepoConstants.XDS_CODING_SCHEME_SLOT, 0)) .thenReturn(EVENT_SCHEME); when(classificationType.getName()).thenReturn(internationalString); when(internationalString.getLocalizedString()).thenReturn(eventCodeDisplayNameList); docRepo.extractEventCodes(doc, classifications); EventCode event = doc.getEventCodes().iterator().next(); assertEquals(NODE_REP, event.getEventCode()); assertEquals(EVENT_CODE_DISPLAY_NAME, event.getEventCodeDisplayName()); assertEquals(EVENT_SCHEME, event.getEventCodeScheme()); }