{
// delete the one generated by the test class
this.lookup(LdapConfigurationManager.class).deleteLdapServerConfiguration("default");
List<String> expectedIds = new ArrayList<String>();
PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerListPlexusResource");
Request request = this.buildRequest();
// ONE
LdapServerRequest ldapServerRequest = new LdapServerRequest();
LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
ldapServerRequest.setData(dto);
dto.setName("testGet-1");
dto.setConnectionInfo(this.buildConnectionInfoDTO());
dto.getConnectionInfo().setHost("testGet1");
dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());
LdapServerRequest postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
Assert.assertNotNull(postResult.getData().getId());
expectedIds.add(postResult.getData().getId());
// TWO
ldapServerRequest = new LdapServerRequest();
dto = new LdapServerConfigurationDTO();
ldapServerRequest.setData(dto);
dto.setName("testGet-2");
dto.setConnectionInfo(this.buildConnectionInfoDTO());
dto.getConnectionInfo().setPort(7788);
dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());
postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
Assert.assertNotNull(postResult.getData().getId());
expectedIds.add(postResult.getData().getId());
// THREE
ldapServerRequest = new LdapServerRequest();
dto = new LdapServerConfigurationDTO();
ldapServerRequest.setData(dto);
dto.setName("testGet-3");
dto.setConnectionInfo(this.buildConnectionInfoDTO());
dto.getConnectionInfo().setSearchBase("ou=testGet3");
dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());
postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
Assert.assertNotNull(postResult.getData().getId());
expectedIds.add(postResult.getData().getId());
// now test get
LdapServerListResponse listResponse = (LdapServerListResponse) pr.get(null, request, null, null);
List<LdapServerListEntryDTO> results = listResponse.getData();
//these should be in order as they where created
Assert.assertEquals(expectedIds.get(0), results.get(0).getId());
Assert.assertEquals("testGet-1", results.get(0).getName());