diff --git a/scim-core/src/test/java/org/apache/directory/scim/core/repository/PatchHandlerTest.java b/scim-core/src/test/java/org/apache/directory/scim/core/repository/PatchHandlerTest.java index 9583ea86..6922756c 100644 --- a/scim-core/src/test/java/org/apache/directory/scim/core/repository/PatchHandlerTest.java +++ b/scim-core/src/test/java/org/apache/directory/scim/core/repository/PatchHandlerTest.java @@ -76,6 +76,26 @@ public void applyReplaceComplexAttribute() { assertThat(updatedUser.getName().getGivenName()).isNotNull(); } + @Test + public void applyReplaceNestedComplexAttribute() { + // setup existing user + Name existingName = new Name(); + existingName.setFamilyName("Family Name"); + existingName.setGivenName("Given Name"); + ScimUser user = user(); + user.setName(existingName); + + // setup patch ops + Map> newName = Map.of("name", Map.of("familyName", "New Family Name")); + PatchOperation op = patchOperation(REPLACE, null, newName); + + //execute + ScimUser updatedUser = patchHandler.apply(user, List.of(op)); + assertThat(updatedUser.getName().getFamilyName()).isEqualTo("New Family Name"); + // assert that PATCH did not update fields not provided in PatchOperation + assertThat(updatedUser.getName().getGivenName()).isNotNull(); + } + @Test public void applyReplaceUserName() { String newUserName = "testUser_updated@test.com";