@Test
    public void testCreateUpdateFindDelete() {
        val profile = new CommonProfile();
        profile.setId(TEST_ID);
        profile.setLinkedId(TEST_LINKED_ID);
        profile.addAttribute(USERNAME, TEST_USER);
        // create
        inMemoryProfileService.create(profile, TEST_PASS);
        // check credentials
        val credentials = new UsernamePasswordCredentials(TEST_USER, TEST_PASS);
        inMemoryProfileService.validate(new CallContext(null, null), credentials);
        val profile1 = credentials.getUserProfile();
        assertNotNull(profile1);
        // check data
        val results = getData(TEST_ID);
        assertEquals(1, results.size());
        val result = results.get(0);
        assertEquals(5, result.size());
        assertEquals(TEST_ID, result.get("id"));
        assertEquals(TEST_LINKED_ID, result.get(AbstractProfileService.LINKEDID));
        assertNotNull(result.get(AbstractProfileService.SERIALIZED_PROFILE));
        assertEquals(TEST_USER, result.get(USERNAME));
        // findById
        val profile2 = inMemoryProfileService.findById(TEST_ID);
        assertEquals(TEST_ID, profile2.getId());
        assertEquals(TEST_LINKED_ID, profile2.getLinkedId());
        assertEquals(TEST_USER, profile2.getUsername());
        assertEquals(1, profile2.getAttributes().size());
        // update with password
        profile.addAttribute(USERNAME, TEST_USER2);
        inMemoryProfileService.update(profile, TEST_PASS2);
        var results2 = getData(TEST_ID);
        assertEquals(1, results2.size());
        var result2 = results2.get(0);
        assertEquals(5, result2.size());
        assertEquals(TEST_ID, result2.get("id"));
        assertEquals(TEST_LINKED_ID, result2.get(AbstractProfileService.LINKEDID));
        assertNotNull(result2.get(AbstractProfileService.SERIALIZED_PROFILE));
        assertEquals(TEST_USER2, result2.get(USERNAME));
        // check credentials
        val credentials2 = new UsernamePasswordCredentials(TEST_USER2, TEST_PASS2);
        inMemoryProfileService.validate(new CallContext(null, null), credentials2);
        val profile3 = credentials.getUserProfile();
        assertNotNull(profile3);
        // update with no password update
        inMemoryProfileService.update(profile, null);
        results2 = getData(TEST_ID);
        assertEquals(1, results2.size());
        result2 = results2.get(0);
        assertEquals(5, result2.size());
        assertEquals(TEST_USER2, result2.get(USERNAME));
        // check credentials
        inMemoryProfileService.validate(new CallContext(null, null), credentials2);
        val profile4 = credentials.getUserProfile();
        assertNotNull(profile4);
        // remove
        inMemoryProfileService.remove(profile);
        val results3 = getData(TEST_ID);
        assertEquals(0, results3.size());
    }
Tests the {@link InMemoryProfileService}.

@author Elie Roux
@since 2.1.0
pac4j-core/src/test/java/org/pac4j/core/profile/service/InMemoryProfileServiceTests.java