DefaultValuesAuthenticationSourceDecorator implements
        AuthenticationSource, InitializingBean { public String getPrincipal() { String principal = target.getPrincipal(); if (StringUtils.hasText(principal)) { return principal; } else { return defaultUser; } } DefaultValuesAuthenticationSourceDecorator();  DefaultValuesAuthenticationSourceDecorator(
            AuthenticationSource target, String defaultUser,
            String defaultPassword); String getCredentials(); String getPrincipal(); void setDefaultPassword(String defaultPassword); void setDefaultUser(String defaultUser); void setTarget(AuthenticationSource target); void afterPropertiesSet();  }
@Test public void testGetPrincipal_TargetHasPrincipal() { when(authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser"); String principal = tested.getPrincipal(); assertThat(principal).isEqualTo("cn=someUser"); }
@Test public void testGetPrincipal_TargetHasNoPrincipal() { when(authenticationSourceMock.getPrincipal()).thenReturn(""); String principal = tested.getPrincipal(); assertThat(principal).isEqualTo(DEFAULT_USER); }