DATAREST-1356 - Fix updating single associations.

Correct a regression regarding association links. Introduce several test cases to prove this situation is fixed regarding PUTs for association links.

Source of the bug: 554d6cb27b (diff-1d7c16fe1992fef13a47fa8ab8599718L317) flips the criteria from "not single" to "single" without checking for related impacts.
This commit is contained in:
Ľubomír Varga
2019-10-03 05:20:31 +02:00
committed by Greg Turnquist
parent 1e588b5c5a
commit 87f9904e3a
3 changed files with 78 additions and 2 deletions

View File

@@ -77,6 +77,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
* @author Jon Brisbin
* @author Oliver Gierke
* @author Greg Turnquist
* @author Ľubomír Varga
*/
@RepositoryRestController
@SuppressWarnings({ "unchecked" })
@@ -318,7 +319,7 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro
"Cannot PATCH a reference to this singular property since the property type is not a List or a Map.");
}
if (source.getLinks().hasSingleLink()) {
if (!source.getLinks().hasSingleLink()) {
throw new IllegalArgumentException(
"Must send only 1 link to update a property reference that isn't a List or a Map.");
}