DATAREST-95 - General overhaul of HTTP method handling.

Code polishing in DomainObjectMerger and related test cases. Fixed the related test cases. Cleanups in ControllerUtils to remove unneeded constants and make sure we really render no content for empty responses.

Refactorings in controller classes to reduce code duplication. We now do not allow POST requests for partial updates to property reference resources anymore but require the usage of PATCH.

Tweaked test helper methods to correctly implement basic interaction patterns.

Related pull request: #127.
This commit is contained in:
Oliver Gierke
2014-02-14 13:20:03 +01:00
parent d65179ccc8
commit b3b091e309
11 changed files with 204 additions and 203 deletions

View File

@@ -17,6 +17,7 @@ package org.springframework.data.rest.core.support;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.springframework.data.rest.core.support.DomainObjectMerger.NullHandlingPolicy.*;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,7 +58,7 @@ public class DomainObjectMergerTests {
Person existingDomainObject = new Person("Frodo", "Baggins");
DomainObjectMerger merger = new DomainObjectMerger(repositories, conversionService);
merger.merge(incoming, existingDomainObject, DomainObjectMerger.MergeNullPolicy.APPLY_NULLS);
merger.merge(incoming, existingDomainObject, APPLY_NULLS);
assertThat(existingDomainObject.getFirstName(), equalTo(incoming.getFirstName()));
assertThat(existingDomainObject.getLastName(), equalTo(incoming.getLastName()));
@@ -76,7 +77,7 @@ public class DomainObjectMergerTests {
Person existingDomainObject = new Person("Frodo", "Baggins");
DomainObjectMerger merger = new DomainObjectMerger(repositories, conversionService);
merger.merge(incoming, existingDomainObject, DomainObjectMerger.MergeNullPolicy.APPLY_NULLS);
merger.merge(incoming, existingDomainObject, APPLY_NULLS);
assertThat(existingDomainObject.getFirstName(), equalTo(incoming.getFirstName()));
assertThat(existingDomainObject.getLastName(), equalTo(incoming.getLastName()));