AdapterComponentDocRepositoryHelper { String extractClassificationMetadata(List<ClassificationType> classifications, String classificationSchemeUUID, String slotName, int valueIndex) { String classificationValue = null; for (ClassificationType classification : classifications) { if (classificationSchemeUUID.equals(classification.getClassificationScheme())) { classificationValue = extractMetadataFromSlots(classification.getSlot(), slotName, valueIndex); break; } } return classificationValue; }    }
@Test public void testExtractClassificationMetadata() { final String CLASS_VALUE = "Classfication value"; final String CLASS_SCHEME_NAME = "classificationSchemeName"; AdapterComponentDocRepositoryHelper docRepoHelper = new AdapterComponentDocRepositoryHelper() { @Override String extractMetadataFromSlots(List<SlotType1> documentSlots, String slotName, int valueIndex) { return CLASS_VALUE; } }; List<ClassificationType> classifications = new ArrayList<>(); ClassificationType classType = mock(ClassificationType.class); classifications.add(classType); when(classType.getClassificationScheme()).thenReturn(CLASS_SCHEME_NAME); String result = docRepoHelper.extractClassificationMetadata(classifications, CLASS_SCHEME_NAME, "slotName", 0); assertEquals(result, CLASS_VALUE); }
@Test public void testExtractClassificationMetadata2() { AdapterComponentDocRepositoryHelper docRepoHelper = new AdapterComponentDocRepositoryHelper(); String result; List<ClassificationType> classifications = new ArrayList(); ClassificationType classificationType = mock(ClassificationType.class); classifications.add(classificationType); InternationalStringType internationalString = mock(InternationalStringType.class); LocalizedStringType localizedString = new LocalizedStringType(); final String VALUE = "classification Value"; localizedString.setValue(VALUE); List<LocalizedStringType> localizedList = new ArrayList(); localizedList.add(localizedString); final String CLASSIFICATION_SCHEME = "classificationScheme"; when(classificationType.getClassificationScheme()).thenReturn(CLASSIFICATION_SCHEME); when(classificationType.getName()).thenReturn(internationalString); when(internationalString.getLocalizedString()).thenReturn(localizedList); result = docRepoHelper.extractClassificationMetadata(classifications, CLASSIFICATION_SCHEME, DocRepoConstants.XDS_NAME); assertEquals(result, VALUE); when(classificationType.getNodeRepresentation()).thenReturn(VALUE); result = docRepoHelper.extractClassificationMetadata(classifications, CLASSIFICATION_SCHEME, DocRepoConstants.XDS_NODE_REPRESENTATION); assertEquals(result, VALUE); when(classificationType.getClassifiedObject()).thenReturn(VALUE); result = docRepoHelper.extractClassificationMetadata(classifications, CLASSIFICATION_SCHEME, DocRepoConstants.XDS_CLASSIFIED_OBJECT); assertEquals(result, VALUE); result = docRepoHelper.extractClassificationMetadata(classifications, CLASSIFICATION_SCHEME, DocRepoConstants.XDS_CLASSIFICATION_ID); assertEquals(result, VALUE); }