AuthenticationManagerImpl implements FactoryBean { public AuthenticationManager getObject() throws Exception { AuthenticationManager authenticationManager = null; for (AuthenticationManager authManager : this.authenticationManagers) { if (authManager instanceof AuthenticationManagerLdapImpl && ldapProviderEnabled) { authenticationManager = authManager; } if (authManager instanceof AuthenticationManagerDaoImpl && !ldapProviderEnabled) { authenticationManager = authManager; } } return authenticationManager; } AuthenticationManagerImpl(boolean ldapProviderEnabled, List<AuthenticationManager> authenticationManagers); AuthenticationManager getObject(); Class getObjectType(); boolean isSingleton();  }
@Test public void shouldReturnAuthenticationManagerLdapTest() throws Exception { sut = new AuthenticationManagerImpl(true, list).getObject(); assertThat(sut, is(instanceOf(AuthenticationManagerLdapImpl.class))); }
@Test public void shouldReturnAuthenticationManagerDaoTest() throws Exception { sut = new AuthenticationManagerImpl(false, list).getObject(); assertThat(sut, is(instanceOf(AuthenticationManagerDaoImpl.class))); }
@Test public void checkPasswordLdapTest() throws Exception { sut = new AuthenticationManagerImpl(true, list).getObject(); sut.checkPassword(user, PASSWORD); verify(authenticationManagerLdap).checkPassword(user, PASSWORD); }
@Test public void checkPasswordDaoTest() throws Exception { sut = new AuthenticationManagerImpl(false, list).getObject(); sut.checkPassword(user, PASSWORD); verify(authenticationManagerDao).checkPassword(user, PASSWORD); }
@Test public void changePasswordLdapTest() throws Exception { sut = new AuthenticationManagerImpl(true, list).getObject(); sut.changePassword(user, PASSWORD); verify(authenticationManagerLdap).changePassword(user, PASSWORD); }
@Test public void changePasswordDaoTest() throws Exception { sut = new AuthenticationManagerImpl(false, list).getObject(); sut.changePassword(user, PASSWORD); verify(authenticationManagerDao).changePassword(user, PASSWORD); }
@Test public void resetPasswordLdapTest() throws Exception { sut = new AuthenticationManagerImpl(true, list).getObject(); sut.resetPassword(user, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING); verify(authenticationManagerLdap).resetPassword(user, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING); }
@Test public void resetPasswordDaoTest() throws Exception { sut = new AuthenticationManagerImpl(false, list).getObject(); sut.resetPassword(user, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING); verify(authenticationManagerDao).resetPassword(user, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING, RANDOM_STRING); }