@Test public void testReplace() throws BadRequestException { ResourcePreparer<ScimResource> preparer = new ResourcePreparer<>(resourceTypeDefinition, attributes, excludedAttributes, testBaseUri); GenericScimResource prepared = preparer.trimReplacedResource(testResource, null); assertTrue(prepared.getObjectNode().has("always")); if (excludedAttributes != null && excludedAttributes.equalsIgnoreCase("always.default")) { assertFalse(prepared.getObjectNode().get("always").has("default")); } assertFalse(prepared.getObjectNode().has("never")); if ((attributes == null && excludedAttributes == null) || (excludedAttributes != null && !excludedAttributes.equalsIgnoreCase( "urn:test:default") && !excludedAttributes.equalsIgnoreCase("default.default")) || (attributes != null && (attributes.equalsIgnoreCase( "urn:test:default") || attributes.equalsIgnoreCase("default.default")))) { assertTrue(prepared.getObjectNode().has("default")); if (attributes != null && attributes.equalsIgnoreCase("default.default")) { assertTrue(prepared.getObjectNode().get("default").has("default")); assertFalse(prepared.getObjectNode().get("default").has("notDeclared")); } if (attributes != null && attributes.equalsIgnoreCase("urn:test:default")) { assertTrue(prepared.getObjectNode().get("default").has("default")); assertTrue(prepared.getObjectNode().get("default").has("notDeclared")); } } else { if (excludedAttributes != null && excludedAttributes.equalsIgnoreCase("default.default")) { assertTrue(prepared.getObjectNode().has("default")); assertFalse(prepared.getObjectNode().get("default").has("default")); assertTrue(prepared.getObjectNode().get("default").has("notDeclared")); assertTrue(prepared.getObjectNode().get("default").has("always")); } else { assertFalse(prepared.getObjectNode().has("default")); } } if (attributes != null && attributes.equalsIgnoreCase("request")) { assertTrue(prepared.getObjectNode().has("request")); } else { assertFalse(prepared.getObjectNode().has("request")); } prepared = preparer.trimReplacedResource(testResource, testResource); assertTrue(prepared.getObjectNode().has("always")); if (excludedAttributes != null && excludedAttributes.equalsIgnoreCase("always.default")) { assertFalse(prepared.getObjectNode().get("always").has("default")); } assertFalse(prepared.getObjectNode().has("never")); if ((attributes == null && excludedAttributes == null) || (excludedAttributes != null && !excludedAttributes.equalsIgnoreCase( "urn:test:default") && !excludedAttributes.equalsIgnoreCase("default.default")) || (attributes != null && (attributes.equalsIgnoreCase( "urn:test:default") || attributes.equalsIgnoreCase("default.default")))) { assertTrue(prepared.getObjectNode().has("default")); if (attributes != null && attributes.equalsIgnoreCase("default.default")) { assertTrue(prepared.getObjectNode().get("default").has("default")); assertFalse(prepared.getObjectNode().get("default").has("notDeclared")); } if (attributes != null && attributes.equalsIgnoreCase("urn:test:default")) { assertTrue(prepared.getObjectNode().get("default").has("default")); assertTrue(prepared.getObjectNode().get("default").has("notDeclared")); } } else { if (excludedAttributes != null && excludedAttributes.equalsIgnoreCase("default.default")) { assertTrue(prepared.getObjectNode().has("default")); assertFalse(prepared.getObjectNode().get("default").has("default")); assertTrue(prepared.getObjectNode().get("default").has("notDeclared")); assertTrue(prepared.getObjectNode().get("default").has("always")); } else { assertFalse(prepared.getObjectNode().has("default")); } } assertTrue(prepared.getObjectNode().has("request")); }
public GenericScimResource trimReplacedResource(final T returnedResource, final T requestResource) { return trimReturned(returnedResource, requestResource, null); }
ResourcePreparer { public GenericScimResource trimReplacedResource(final T returnedResource, final T requestResource) { return trimReturned(returnedResource, requestResource, null); } }
ResourcePreparer { public GenericScimResource trimReplacedResource(final T returnedResource, final T requestResource) { return trimReturned(returnedResource, requestResource, null); } ResourcePreparer(final ResourceTypeDefinition resourceType,
                            final String attributesString,
                            final String excludedAttributesString,
                            final URI baseUri); }
ResourcePreparer { public GenericScimResource trimReplacedResource(final T returnedResource, final T requestResource) { return trimReturned(returnedResource, requestResource, null); } ResourcePreparer(final ResourceTypeDefinition resourceType,
                            final String attributesString,
                            final String excludedAttributesString,
                            final URI baseUri); GenericScimResource trimRetrievedResource(final T returnedResource); GenericScimResource trimCreatedResource(final T returnedResource, final T requestResource); GenericScimResource trimReplacedResource(final T returnedResource, final T requestResource); GenericScimResource trimModifiedResource(final T returnedResource, final Iterable<PatchOperation> patchOperations); void setResourceTypeAndLocation(final T returnedResource); }
ResourcePreparer { public GenericScimResource trimReplacedResource(final T returnedResource, final T requestResource) { return trimReturned(returnedResource, requestResource, null); } ResourcePreparer(final ResourceTypeDefinition resourceType,
                            final String attributesString,
                            final String excludedAttributesString,
                            final URI baseUri); GenericScimResource trimRetrievedResource(final T returnedResource); GenericScimResource trimCreatedResource(final T returnedResource, final T requestResource); GenericScimResource trimReplacedResource(final T returnedResource, final T requestResource); GenericScimResource trimModifiedResource(final T returnedResource, final Iterable<PatchOperation> patchOperations); void setResourceTypeAndLocation(final T returnedResource);  }