/** * {@inheritDoc} */ @Override public void serialize(final GenericScimResource value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException { JsonUtils.getObjectWriter().writeValue(jgen, value.getObjectNode()); } }
/** * {@inheritDoc} */ @Override public void serialize(final GenericScimResource value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException { JsonUtils.getObjectWriter().writeValue(jgen, value.getObjectNode()); } }
/** * Apply this patch request to the GenericScimResourceObject. * * @param object The GenericScimResourceObject to apply this patch to. * * @throws ScimException If the one or more patch operations is invalid. */ public void apply(final GenericScimResource object) throws ScimException { for(PatchOperation operation : this) { operation.apply(object.getObjectNode()); } }
/** * Apply this patch request to the GenericScimResourceObject. * * @param object The GenericScimResourceObject to apply this patch to. * * @throws ScimException If the one or more patch operations is invalid. */ public void apply(final GenericScimResource object) throws ScimException { for(PatchOperation operation : this) { operation.apply(object.getObjectNode()); } }
((GenericScimResource) resource).getObjectNode().deepCopy()); genericResource.getObjectNode()))
/** * Test the findMatchingPaths method. * * @throws ScimException If an error occurred. * @throws IOException If an error occurred. */ @Test public void testGetArray() throws ScimException, IOException { GenericScimResource gso = new GenericScimResource(getTestResource()); List<JsonNode> mapResult = JsonUtils.findMatchingPaths( Path.fromString("array"), gso.getObjectNode()); assertEquals(mapResult.size(), 1); assertEquals(mapResult.get(0).size(), 2); assertEquals(mapResult.get(0).get(0).size(), 11); mapResult = JsonUtils.findMatchingPaths( Path.fromString("complex.array[id eq \"2\"]"), gso.getObjectNode()); assertEquals(mapResult.size(), 1); assertEquals(mapResult.get(0).size(), 1); assertEquals(mapResult.get(0).get(0).size(), 11); }
/** * Test the findMatchingPaths method. * * @throws ScimException If an error occurred. * @throws IOException If an error occurred. */ @Test public void testGetComplex() throws ScimException, IOException { GenericScimResource gso = new GenericScimResource(getTestResource()); List<JsonNode> mapResult = JsonUtils.findMatchingPaths( Path.fromString("array.complex"), gso.getObjectNode()); assertEquals(mapResult.size(), 2); assertEquals(mapResult.get(0).size(), 9); mapResult = JsonUtils.findMatchingPaths( Path.fromString("aRray[ID eq \"2\"].cOmplex"), gso.getObjectNode()); assertEquals(mapResult.size(), 1); assertEquals(mapResult.get(0).size(), 9); }
requestResource.asGenericScimResource().getObjectNode(); requestAttributes = new LinkedHashSet<Path>(); collectAttributes(Path.root(), requestAttributes, requestObject); GenericScimResource preparedResource = new GenericScimResource( trimmer.trimObjectNode(genericReturnedResource.getObjectNode())); return preparedResource;
if (filter.visit(filterEvaluator, resource.getObjectNode()))
if(filter.visit(filterEvaluator, resource.getObjectNode()))
/** * Tests that the pathExists method works in a variety of situations. * * @param jsonString the string representation of the json to check. * @param path the path to check the existence of. * @param shouldExist true if it should exist, false if not. * @throws Exception thrown in case of an error. */ @Test(dataProvider = "pathExistsDataProvider") public void testPathExists(String jsonString, Path path, boolean shouldExist) throws Exception { GenericScimResource resource = JsonUtils.getObjectReader().forType( GenericScimResource.class).readValue(jsonString); Assert.assertEquals( JsonUtils.pathExists(path, resource.getObjectNode()), shouldExist); }
/** * Test that filters matching. * * @param filter The filter string to evaluate. * @param result The expected result. * @throws ScimException If the filter string is invalid. */ @Test(dataProvider = "getTestValidFilterStrings") public void testFilter(String filter, boolean result) throws ScimException { SchemaAwareFilterEvaluator filterEvaluator = new SchemaAwareFilterEvaluator(resourceTypeDefinition); boolean actualResult = Filter.fromString(filter).visit( filterEvaluator, testResource.getObjectNode()); assertEquals(actualResult, result); } }
/** * Test conversion to GenericScimResource. * * @throws IOException indicates a test failure. */ @Test public void testAsGenericScimResource() throws IOException { UserResource userResource1 = JsonUtils.getObjectReader().forType(UserResource.class).readValue( fullRepresentation); GenericScimResource gsr = userResource1.asGenericScimResource(); UserResource userResource2 = JsonUtils.nodeToValue(gsr.getObjectNode(), UserResource.class); Assert.assertEquals(userResource1, userResource2); }
Path.fromString("array.complex.array.string"), gso.getObjectNode()); assertEquals(stringResult.size(), 4); assertEquals(stringResult.get(0).textValue(), "string"); gso.getObjectNode()); assertEquals(stringResult.size(), 2); assertEquals(stringResult.get(0).textValue(), "string"); gso.getObjectNode()); assertEquals(stringResult.size(), 2); assertEquals(stringResult.get(0).textValue(), "string"); gso.getObjectNode()); assertEquals(stringResult.size(), 1); assertEquals(stringResult.get(0).textValue(), "string"); Path.fromString("complex.array.array.string"), gso.getObjectNode()); assertEquals(stringResult.size(), 4); assertEquals(stringResult.get(0).textValue(), "string"); Path.fromString("array.complex"), gso.getObjectNode()); assertEquals(mapResult.size(), 2); assertEquals(mapResult.get(0).size(), 9);
private void verifyEtagHeaders(GenericScimResource resource, boolean shouldContainIfMatch, boolean shouldContainIfNoneMatch) throws ScimException { if(shouldContainIfMatch) { List<String> ifMatchValues = resource.getStringValueList(HttpHeaders.IF_MATCH); Assert.assertNotNull(ifMatchValues); Assert.assertFalse(ifMatchValues.isEmpty()); } else { Assert.assertTrue(resource.getObjectNode(). path(HttpHeaders.IF_MATCH).isMissingNode()); } if(shouldContainIfNoneMatch) { List<String> ifNoneMatchValues = resource.getStringValueList(HttpHeaders.IF_NONE_MATCH); Assert.assertNotNull(ifNoneMatchValues); Assert.assertFalse(ifNoneMatchValues.isEmpty()); } else { Assert.assertTrue(resource.getObjectNode(). path(HttpHeaders.IF_NONE_MATCH).isMissingNode()); } }
Path.fromString("String"), gso.getObjectNode()); assertEquals(stringResult.size(), 1); assertEquals(stringResult.get(0).textValue(), "string"); Path.fromString("integeR"), gso.getObjectNode()); assertEquals(intResult.size(), 1); assertEquals(intResult.get(0).intValue(), 1); Path.fromString("deCimal"), gso.getObjectNode()); assertEquals(decimalResult.size(), 1); assertEquals(decimalResult.get(0).doubleValue(), 1.582); Path.fromString("boolean"), gso.getObjectNode()); assertEquals(booleanResult.size(), 1); assertEquals(booleanResult.get(0).booleanValue(), true); Path.fromString("date"), gso.getObjectNode()); assertEquals(dateResult.size(), 1); assertEquals( Path.fromString("binary"), gso.getObjectNode()); assertEquals(binaryResult.size(), 1); assertEquals(binaryResult.get(0).binaryValue(), "binary".getBytes());
Path.fromString("array"), gso.getObjectNode()).get(0), ArrayValue[].class)[0], meta1); assertNotEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("array"), gso.getObjectNode()).get(0), ArrayValue[].class)[1], meta2); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("array"), gso.getObjectNode()).get(0), ArrayValue[].class)[2], meta1); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("array"), gso.getObjectNode()).get(0), ArrayValue[].class)[3], meta2); Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class).length, 4); assertNotEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class)[0], meta1); assertNotEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class)[1], meta2); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class)[2], meta1); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class)[3], meta2);
gso.getObjectNode()).get(0), String.class), "new"); Path.fromString("array.string"), gso.getObjectNode()).get(0), String.class), "new"); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("array.string"), gso.getObjectNode()).get(1), String.class), "new"); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array.array.string"), gso.getObjectNode()).get(0), String.class), "string"); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array.array.string"), gso.getObjectNode()).get(1), String.class), "new"); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array.array.string"), gso.getObjectNode()).get(2), String.class), "string"); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array.array.string"), gso.getObjectNode()).get(3), String.class), "new"); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.root("urn:some:extension").attribute("attribute"), gso.getObjectNode()).get(0), String.class), "extensionValue");
Path.fromString("array.complex"), gso.getObjectNode()).get(0), ArrayValue.class); value0.set("version", "new"); ArrayValue value1 = JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("array.complex"), gso.getObjectNode()).get(1), ArrayValue.class); value1.set("version", "new"); Path.fromString("array.complex"), gso.getObjectNode()).get(0), ArrayValue.class), value0); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("array.complex"), gso.getObjectNode()).get(1), ArrayValue.class), value1); Path.fromString("complex.array.complex"), gso.getObjectNode()).get(0), ArrayValue.class), value0); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array.complex"), gso.getObjectNode()).get(1), ArrayValue.class), value1); JsonUtils.valueToNode(meta)); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.root("urn:some:extension"), gso.getObjectNode()).get(0), ArrayValue.class), meta);
JsonUtils.valueToNode(new ArrayValue[]{meta1, meta2})); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("array"), gso.getObjectNode()).get(0), ArrayValue[].class), values); gso.getObjectNode()).get(0), ArrayValue[].class); value1[0].set("version", "1"); Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class)[0], value1[0]); assertNotEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class)[0], value1[0]); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.fromString("complex.array"), gso.getObjectNode()).get(0), ArrayValue[].class)[1], value1[0]); assertEquals(JsonUtils.nodeToValue(JsonUtils.findMatchingPaths( Path.root("urn:some:extension").attribute("attribute"), gso.getObjectNode()).get(0), ArrayValue[].class), values);