From 51c2e9e4453b4f043c84e5c85a3cfd400f2d77a8 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Mon, 1 Apr 2019 11:52:24 +0200 Subject: [PATCH] DATAJPA-1519 - Fixed broken test. Made the test more specific which demonstrated that the test was broken in the first place. --- .../data/jpa/repository/UserRepositoryFinderTests.java | 7 ++++++- .../data/jpa/repository/sample/UserRepository.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java b/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java index 1991c582c..49e4dc5e8 100644 --- a/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java +++ b/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java @@ -205,7 +205,12 @@ public class UserRepositoryFinderTests { @Test // DATAJPA-1519 public void escapingInLikeSpels() { - assertThat(userRepository.findContainingEscaped("att_"), iterableWithSize(0)); + + User extra = new User("extra", "Matt_ew", "extra"); + userRepository.save(extra); + + List result = userRepository.findContainingEscaped("att_"); + assertThat(result, containsInAnyOrder(extra)); } @Test // DATAJPA-829 diff --git a/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java b/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java index 30d3aa335..3e4b2cb1b 100644 --- a/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java +++ b/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java @@ -557,7 +557,7 @@ public interface UserRepository List findByNamedQueryWithConstructorExpression(); // DATAJPA-1519 - @Query("select u from User u where u.firstname like %?#{escape([0])}% escape ?#{escapeCharacter()}") + @Query("select u from User u where u.lastname like %?#{escape([0])}% escape ?#{escapeCharacter()}") List findContainingEscaped(String namePart); interface RolesAndFirstname {