@Test
    public void testCreateUpdateFindDelete() {
        val profile = new LdapProfile();
        profile.setId(LDAP_ID);
        profile.setLinkedId(LDAP_LINKED_ID);
        profile.addAttribute(USERNAME, LDAP_USER);
        val ldapProfileService = new LdapProfileService(connectionFactory, authenticator, LdapServer.BASE_PEOPLE_DN);
        ldapProfileService.setIdAttribute(LdapServer.CN);
        ldapProfileService.setUsernameAttribute(LdapServer.SN);
        ldapProfileService.setPasswordAttribute("userPassword");
        // create
        ldapProfileService.create(profile, LDAP_PASS);
        // check credentials
        val credentials = new UsernamePasswordCredentials(LDAP_ID, LDAP_PASS);
        ldapProfileService.validate(null, credentials);
        val profile1 = credentials.getUserProfile();
        assertNotNull(profile1);
        // check data
        val results = getData(ldapProfileService, LDAP_ID);
        assertEquals(1, results.size());
        val result = results.get(0);
        assertEquals(4, result.size());
        assertEquals(LDAP_ID, result.get(LdapServer.CN));
        assertEquals(LDAP_LINKED_ID, result.get(AbstractProfileService.LINKEDID));
        assertNotNull(result.get(AbstractProfileService.SERIALIZED_PROFILE));
        assertEquals(LDAP_USER, result.get(LdapServer.SN));
        // findById
        val profile2 = ldapProfileService.findById(LDAP_ID);
        assertEquals(LDAP_ID, profile2.getId());
        assertEquals(LDAP_LINKED_ID, profile2.getLinkedId());
        assertEquals(LDAP_USER, profile2.getUsername());
        assertEquals(1, profile2.getAttributes().size());
        // update
        profile.addAttribute(USERNAME, LDAP_USER2);
        ldapProfileService.update(profile, LDAP_PASS2);
        val results2 = getData(ldapProfileService, LDAP_ID);
        assertEquals(1, results2.size());
        val result2 = results2.get(0);
        assertEquals(4, result2.size());
        assertEquals(LDAP_ID, result2.get(LdapServer.CN));
        assertEquals(LDAP_LINKED_ID, result2.get(AbstractProfileService.LINKEDID));
        assertNotNull(result2.get(AbstractProfileService.SERIALIZED_PROFILE));
        assertEquals(LDAP_USER2, result2.get(LdapServer.SN));
        // check credentials
        val credentials2 = new UsernamePasswordCredentials(LDAP_ID, LDAP_PASS2);
        ldapProfileService.validate(null, credentials2);
        val profile3 = credentials.getUserProfile();
        assertNotNull(profile3);
        // remove
        ldapProfileService.remove(profile);
        val results3 = getData(ldapProfileService, LDAP_ID);
        assertEquals(0, results3.size());
    }
Tests the {@link LdapProfileService}.

@author Jerome Leleu
@since 1.8.0
pac4j-ldap/src/test/java/org/pac4j/ldap/profile/service/LdapProfileServiceTests.java