From 0aa37e0b280a89acbabc8f9348136587f6dd40be Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 6 Dec 2016 10:54:14 +0100 Subject: [PATCH] DATACMNS-953 - Fixed application of GenericPropertyMatchers.exact(). We now really use exact matching for a match setup requesting exact matching. Previously, we erroneously set up the matching with a startsWith(). --- .../data/domain/ExampleMatcher.java | 2 +- .../ExampleSpecificationAccessorUnitTests.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/domain/ExampleMatcher.java b/src/main/java/org/springframework/data/domain/ExampleMatcher.java index a9b4f691c..af9887884 100644 --- a/src/main/java/org/springframework/data/domain/ExampleMatcher.java +++ b/src/main/java/org/springframework/data/domain/ExampleMatcher.java @@ -556,7 +556,7 @@ public class ExampleMatcher { * @return */ public static GenericPropertyMatcher exact() { - return new GenericPropertyMatcher().startsWith(); + return new GenericPropertyMatcher().exact(); } /** diff --git a/src/test/java/org/springframework/data/repository/core/support/ExampleSpecificationAccessorUnitTests.java b/src/test/java/org/springframework/data/repository/core/support/ExampleSpecificationAccessorUnitTests.java index 945fe1f74..44625a83c 100644 --- a/src/test/java/org/springframework/data/repository/core/support/ExampleSpecificationAccessorUnitTests.java +++ b/src/test/java/org/springframework/data/repository/core/support/ExampleSpecificationAccessorUnitTests.java @@ -38,7 +38,6 @@ import org.springframework.data.domain.ExampleMatcher.StringMatcher; * @author Mark Paluch * @soundtrack Ron Spielman Trio - Fretboard Highway (Electric Tales) */ -@SuppressWarnings("unused") public class ExampleSpecificationAccessorUnitTests { Person person; @@ -322,6 +321,19 @@ public class ExampleSpecificationAccessorUnitTests { assertThat(exampleSpecificationAccessor.hasPropertySpecifiers(), is(true)); } + /** + * @see DATACMNS-953 + */ + @Test + public void exactMatcherUsesExactMatching() { + + ExampleMatcher matcher = ExampleMatcher.matching()// + .withMatcher("firstname", exact()); + + assertThat(new ExampleMatcherAccessor(matcher).getPropertySpecifier("firstname").getStringMatcher(), + is(StringMatcher.EXACT)); + } + static class Person { String firstname; }