@Test
  public void testShouldLdapAttributeDetectionDelegateToTheRightServiceCalls() throws Exception {

    // configuration map with user attributes detected
    Map<String, String> userConfigMap = Maps.newHashMap();
    userConfigMap.put(AmbariServerConfigurationKey.USER_NAME_ATTRIBUTE.key(), "uid");
    AmbariLdapConfiguration userAttrDecoratedConfig = new AmbariLdapConfiguration(userConfigMap);

    // configuration map with user+group attributes detected
    Map<String, String> groupConfigMap = Maps.newHashMap(userConfigMap);
    groupConfigMap.put(AmbariServerConfigurationKey.GROUP_NAME_ATTRIBUTE.key(), "dn");
    AmbariLdapConfiguration groupAttrDecoratedConfig = new AmbariLdapConfiguration(groupConfigMap);

    Capture<AmbariLdapConfiguration> userAttrDetectionConfigCapture = Capture.newInstance();
    Capture<AmbariLdapConfiguration> groupAttrDetectionConfigCapture = Capture.newInstance();

    // GIVEN
    EasyMock.expect(ldapAttributeDetectionServiceMock.detectLdapUserAttributes(EasyMock.capture(userAttrDetectionConfigCapture)))
        .andReturn(userAttrDecoratedConfig);

    EasyMock.expect(ldapAttributeDetectionServiceMock.detectLdapGroupAttributes(EasyMock.capture(groupAttrDetectionConfigCapture)))
        .andReturn(groupAttrDecoratedConfig);

    replayAll();

    // WHEN
    AmbariLdapConfiguration detected = ldapFacade.detectAttributes(ambariLdapConfiguration);

    // THEN
    Assert.assertEquals("User attribute detection called with the wrong configuration", ambariLdapConfiguration,
        userAttrDetectionConfigCapture.getValue());

    Assert.assertEquals("Group attribute detection called with the wrong configuration", userAttrDecoratedConfig,
        groupAttrDetectionConfigCapture.getValue());

    Assert.assertEquals("Attribute detection returned an invalid configuration", groupAttrDecoratedConfig, detected);

  }
Tests whether the facade method call delegates to the proper service call.
The thest is success if the same instance is passed to the service.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/ldap/service/AmbariLdapFacadeTest.java