@Test
  public void testShouldDetectAttributeBasedOnOccurrence() throws Exception {
    // GIVEN
    // Mimic a sample set of entries where group membership attributes  are different
    List<Entry> sampleEntryList = Lists.newArrayList();

    sampleEntryList.addAll(getSampleEntryList(GroupMemberAttrDetector.GroupMemberAttr.MEMBER_UID, 2));

    // this is the expected property to be detected as in the sample set the most entries have it
    sampleEntryList.addAll(getSampleEntryList(GroupMemberAttrDetector.GroupMemberAttr.UNIQUE_MEMBER, 7));
    sampleEntryList.addAll(getSampleEntryList(GroupMemberAttrDetector.GroupMemberAttr.MEMBER, 5));

    // WHEN
    for (Entry entry : sampleEntryList) {
      groupMemberAttrDetector.collect(entry);
    }

    // The most frequently encountered attribute will be selected
    Map<String, String> detectedAttributeMap = groupMemberAttrDetector.detect();

    // THEN
    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 suite for the attribute detector implementation
ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupMemberAttrDetectorTest.java