### Question:
GroupMemberAttrDetector extends OccurrenceAndWeightBasedDetector { @Override public String detectedProperty() { return AmbariServerConfigurationKey.GROUP_MEMBER_ATTRIBUTE.key(); } @Inject  GroupMemberAttrDetector(); @Override String detectedProperty();  }### Answer:
@Test public void testShouldDetectAttributeBasedOnOccurrence() throws Exception { List<Entry> sampleEntryList = Lists.newArrayList(); sampleEntryList.addAll(getSampleEntryList(GroupMemberAttrDetector.GroupMemberAttr.MEMBER_UID, 2)); sampleEntryList.addAll(getSampleEntryList(GroupMemberAttrDetector.GroupMemberAttr.UNIQUE_MEMBER, 7)); sampleEntryList.addAll(getSampleEntryList(GroupMemberAttrDetector.GroupMemberAttr.MEMBER, 5)); for (Entry entry : sampleEntryList) { groupMemberAttrDetector.collect(entry); } Map<String, String> detectedAttributeMap = groupMemberAttrDetector.detect(); Assert.assertEquals(1, detectedAttributeMap.size()); Map.Entry<String, String> selectedEntry = detectedAttributeMap.entrySet().iterator().next(); Assert.assertEquals("The selected configuration property is not the expected one", groupMemberAttrDetector.detectedProperty(), selectedEntry.getKey()); Assert.assertEquals("The selected configuration property value is not the expected one", GroupMemberAttrDetector.GroupMemberAttr.UNIQUE_MEMBER.attrName(), selectedEntry.getValue()); }
@Test public void testShouldDetectorPassWhenEmptySampleSetProvided() throws Exception { List<Entry> sampleEntryList = Lists.newArrayList(); for (Entry entry : sampleEntryList) { groupMemberAttrDetector.collect(entry); } Map<String, String> detectedAttributeMap = groupMemberAttrDetector.detect(); Assert.assertEquals(1, detectedAttributeMap.size()); Map.Entry<String, String> selectedEntry = detectedAttributeMap.entrySet().iterator().next(); Assert.assertEquals("The selected configuration property is not the expected one", groupMemberAttrDetector.detectedProperty(), selectedEntry.getKey()); Assert.assertEquals("The selected configuration property value is not the expected one", "N/A", selectedEntry.getValue()); }