@Test
public void testCleanupProfileAdditionalAttributes() {

    // Arrange
    Vertx vertx = mock(Vertx.class);
    when(vertx.eventBus()).thenReturn(mock(EventBus.class));
    ResourceStorage resourceStorage = mock(ResourceStorage.class);
    UserProfileConfiguration userProfileConfiguration =
            UserProfileConfiguration.create()
                    .userProfileUriPattern("/users/v1/([^/]+)/profile")
                    .addAllowedProfileProperties("username", "personalNumber", "fullname", "mail", "department", "lang",
                            "addAttr1", "addAttr2", "addAttr3")
                    .rolePattern("^z-gateleen[-_](.*)$")
                    .build();
    UserProfileHandler userProfileHandler = new UserProfileHandler(vertx, resourceStorage, userProfileConfiguration);
    JsonObject profile = new JsonObject();
    profile.put("personalNumber", "04146251");
    profile.put("username", "john");
    profile.put("mail", "john.doe@swisspush.org");
    profile.put("department", "sales");
    profile.put("lang", "de");
    profile.put("addAttr1", "addVal1");
    profile.put("addAttr2", "addVal2");
    profile.put("addAttr3", "addVal3");
    profile.put("addAttr4", "addVal4");
    // Act
    userProfileHandler.cleanupUserProfile(profile, updatedProfile -> {
        // Assert
        assertThat(updatedProfile.getString("personalNumber"), is("04146251"));
        assertThat(updatedProfile.getString("username"), is("john"));
        assertThat(updatedProfile.getString("mail"), is("john.doe@swisspush.org"));
        assertThat(updatedProfile.getString("department"), is("sales"));
        assertThat(updatedProfile.getString("lang"), is("de"));
        assertThat(updatedProfile.getString("addAttr1"), is("addVal1"));
        assertThat(updatedProfile.getString("addAttr2"), is("addVal2"));
        assertThat(updatedProfile.getString("addAttr3"), is("addVal3"));
        assertThat(updatedProfile.getString("addAttr4"), is(nullValue()));
    });
}