diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/JsonPatchHandler.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/JsonPatchHandler.java index c730460d3..bd4d08ffe 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/JsonPatchHandler.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/JsonPatchHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; * into * * @author Oliver Gierke + * @author Mathias Düsterhöft * @see http://tools.ietf.org/html/rfc6902 * @see http://tools.ietf.org/html/draft-ietf-appsawg-json-merge-patch-02 */ diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonLateObjectEvaluator.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonLateObjectEvaluator.java index 6322a2d0e..55de8965e 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonLateObjectEvaluator.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonLateObjectEvaluator.java @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; * {@link LateObjectEvaluator} implementation that assumes values represented as JSON objects. * * @author Craig Walls - * @author Mathias Düsterhöft */ class JsonLateObjectEvaluator implements LateObjectEvaluator { diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchPatchConverter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchPatchConverter.java index 63d8fb4c8..bf2834cb3 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchPatchConverter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchPatchConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.springframework.util.Assert; + import com.fasterxml.jackson.core.JsonPointer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -30,16 +32,26 @@ import com.fasterxml.jackson.databind.node.ObjectNode; * Convert {@link JsonNode}s containing JSON Patch to/from {@link Patch} objects. * * @author Craig Walls + * @author Oliver Gierke + * @author Mathias Düsterhöft */ public class JsonPatchPatchConverter implements PatchConverter { private final ObjectMapper mapper; - public JsonPatchPatchConverter(ObjectMapper mapper) { - this.mapper = mapper; - } + /** + * Creates a new {@link JsonPatchPatchConverter} for the given {@link ObjectMapper}. + * + * @param mapper must not be {@literal null}. + */ + public JsonPatchPatchConverter(ObjectMapper mapper) { - /** + Assert.notNull(mapper, "ObjectMapper must not be null!"); + + this.mapper = mapper; + } + + /** * Constructs a {@link Patch} object given a JsonNode. * * @param jsonNode a JsonNode containing the JSON Patch diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchTest.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchTest.java index de1bd7e95..1c7590a71 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchTest.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/JsonPatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,13 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +/** + * Unit tests for {@link JsonPatchPatchConverter}. + * + * @author Craig Walls + * @author Oliver Gierke + * @author Mathias Düsterhöft + */ public class JsonPatchTest { @Test