Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## v5.0.1 - TBD
Updated Jackson to 2.20.1.

Updated `ErrorResponse.java` to print attributes in an order that is more consistent with the
example JSON objects presented in RFC 7644. Now, `status` is the last attribute printed.

## v5.0.0 - 2025-Dec-15
For consistency with other open source Ping Identity software, the UnboundID SCIM 2 SDK for Java is
now available under the terms of the Apache License (version 2.0). For legacy compatibility, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.unboundid.scim2.common.annotations.NotNull;
Expand Down Expand Up @@ -85,6 +86,7 @@
*/
@Schema(id="urn:ietf:params:scim:api:messages:2.0:Error",
name="Error Response", description = "SCIM 2.0 Error Response")
@JsonPropertyOrder({"schemas", "scimType", "detail", "status"})
public class ErrorResponse extends BaseScimResource
{
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.unboundid.scim2.common.utils.SchemaUtils;
import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;

/**
Expand Down Expand Up @@ -122,4 +123,37 @@ public void testDeserializationAndSerializationWithNumberStatus()
readValue(serializedString);
assertEquals(errorResponse, deserializedErrorResponse);
}

/**
* Ensures that serialized ErrorResponse objects match the form presented in
* RFC 7644.
*/
@Test
public void testSerialization() throws Exception
{
// Use a JSON string from the RFC with all fields populated.
String json = """
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"],
"scimType": "invalidSyntax",
"detail": "Request is unparsable, syntactically incorrect, or violates schema.",
"status": "400"
}""";
String expectedJSON = JsonUtils.getObjectReader().readTree(json)
.toPrettyString();

// Construct the same data in object form. When the object is printed as a
// string, it should match the expected output.
ErrorResponse errorResponse = new ErrorResponse(400);
errorResponse.setScimType("invalidSyntax");
errorResponse.setDetail(
"Request is unparsable, syntactically incorrect, or violates schema.");
assertThat(errorResponse.toString()).isEqualTo(expectedJSON);

// The string formatting should also match when the error originates from
// an exception object.
BadRequestException e = BadRequestException.invalidSyntax(
"Request is unparsable, syntactically incorrect, or violates schema.");
assertThat(e.getScimError().toString()).isEqualTo(expectedJSON);
}
}
Loading