bdemers commented on code in PR #726:
URL: https://github.com/apache/directory-scimple/pull/726#discussion_r1920522921


##########
scim-core/src/test/java/org/apache/directory/scim/core/repository/PatchHandlerTest.java:
##########
@@ -56,6 +56,46 @@ public PatchHandlerTest() {
     this.patchHandler = new DefaultPatchHandler(schemaRegistry);
   }
 
+  @Test
+  public void applyReplaceComplexAttribute() {
+    // 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<String, String> newName = Map.of("familyName", "New Family Name");
+    PatchOperation op = patchOperation(REPLACE, "name", 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();

Review Comment:
   nit: we may want to assert the original value here instead of null.
   
   ```suggestion
       assertThat(updatedUser.getName().getGivenName()).isEqualTo("Given Name");
   ```



##########
scim-core/src/test/java/org/apache/directory/scim/core/repository/PatchHandlerTest.java:
##########
@@ -56,6 +56,46 @@ public PatchHandlerTest() {
     this.patchHandler = new DefaultPatchHandler(schemaRegistry);
   }
 
+  @Test
+  public void applyReplaceComplexAttribute() {
+    // 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<String, String> newName = Map.of("familyName", "New Family Name");
+    PatchOperation op = patchOperation(REPLACE, "name", 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 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<String, Map<String, String>> 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();

Review Comment:
   ```suggestion
       assertThat(updatedUser.getName().getGivenName()).isEqualTo("Given Name");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to