@Test
public void testSuccess()
throws Exception
{
LdapConfigurationManager ldapConfigurationManager = this.lookup(LdapConfigurationManager.class);
ldapConfigurationManager.deleteLdapServerConfiguration("default");
// add 2 ldapServers
CLdapServerConfiguration ldapServer1 = new CLdapServerConfiguration();
ldapServer1.setName("testSuccess1");
ldapServer1.setConnectionInfo(this.buildConnectionInfo());
ldapServer1.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);
CLdapServerConfiguration ldapServer2 = new CLdapServerConfiguration();
ldapServer2.setName("testSuccess2");
ldapServer2.setConnectionInfo(this.buildConnectionInfo());
ldapServer2.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
ldapConfigurationManager.addLdapServerConfiguration(ldapServer2);
CLdapServerConfiguration ldapServer3 = new CLdapServerConfiguration();
ldapServer3.setName("testSuccess3");
ldapServer3.setConnectionInfo(this.buildConnectionInfo());
ldapServer3.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
ldapConfigurationManager.addLdapServerConfiguration(ldapServer3);
CLdapServerConfiguration ldapServer4 = new CLdapServerConfiguration();
ldapServer4.setName("testSuccess4");
ldapServer4.setConnectionInfo(this.buildConnectionInfo());
ldapServer4.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
ldapConfigurationManager.addLdapServerConfiguration(ldapServer4);
// the order at this point is 1, 2, 3, 4
// we will change it to 3, 1, 4, 2
List<String> newOrder = new ArrayList<String>();
newOrder.add(ldapServer3.getId());
newOrder.add(ldapServer1.getId());
newOrder.add(ldapServer4.getId());
newOrder.add(ldapServer2.getId());
LdapServerOrderRequest orderRequest = new LdapServerOrderRequest();
orderRequest.setData(newOrder);
PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerOrderPlexusResource");
List<String> resultNewOrder = ((LdapServerOrderRequest) pr.put(null, null, null, orderRequest)).getData();
Assert.assertEquals(newOrder, resultNewOrder);
// check for the same order as above
List<CLdapServerConfiguration> ldapServers = ldapConfigurationManager.listLdapServerConfigurations();
Assert.assertEquals(ldapServers.get(0).getId(), ldapServer3.getId());
Assert.assertEquals(ldapServers.get(1).getId(), ldapServer1.getId());
Assert.assertEquals(ldapServers.get(2).getId(), ldapServer4.getId());
Assert.assertEquals(ldapServers.get(3).getId(), ldapServer2.getId());