|
15 | 15 | */
|
16 | 16 | package org.springframework.data.neo4j.repository.support;
|
17 | 17 |
|
18 |
| -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; |
| 18 | +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
19 | 19 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
20 | 20 | import static org.mockito.Mockito.doReturn;
|
21 | 21 | import static org.mockito.Mockito.mock;
|
|
42 | 42 | import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCompositeProperties;
|
43 | 43 | import org.springframework.data.neo4j.repository.Neo4jRepository;
|
44 | 44 | import org.springframework.data.repository.core.RepositoryInformation;
|
| 45 | +import org.springframework.data.repository.query.QueryCreationException; |
45 | 46 |
|
46 | 47 | /**
|
47 | 48 | * @author Gerrit Meier
|
@@ -114,36 +115,36 @@ void prepareContext() {
|
114 | 115 | void validateIgnoreCaseShouldWork() {
|
115 | 116 |
|
116 | 117 |
|
117 |
| - assertThatIllegalArgumentException().isThrownBy(() -> repositoryFactory.getRepository(InvalidIgnoreCase.class)) |
118 |
| - .withMessageMatching("Can not derive query for '.*': Only the case of String based properties can be ignored within the following keywords: \\[IsNotLike, NotLike, IsLike, Like, IsStartingWith, StartingWith, StartsWith, IsEndingWith, EndingWith, EndsWith, IsNotContaining, NotContaining, NotContains, IsContaining, Containing, Contains, IsNot, Not, Is, Equals\\]."); |
| 118 | + assertThatExceptionOfType(QueryCreationException.class).isThrownBy(() -> repositoryFactory.getRepository(InvalidIgnoreCase.class)) |
| 119 | + .withMessageMatching("Could not create query for .*: Only the case of String based properties can be ignored within the following keywords: \\[IsNotLike, NotLike, IsLike, Like, IsStartingWith, StartingWith, StartsWith, IsEndingWith, EndingWith, EndsWith, IsNotContaining, NotContaining, NotContains, IsContaining, Containing, Contains, IsNot, Not, Is, Equals\\]."); |
119 | 120 | }
|
120 | 121 |
|
121 | 122 | @Test
|
122 | 123 | void validateTemporalShouldWork() {
|
123 | 124 |
|
124 |
| - assertThatIllegalArgumentException().isThrownBy(() -> repositoryFactory.getRepository(InvalidTemporal.class)) |
125 |
| - .withMessageMatching("Can not derive query for '.*': The keywords \\[IsAfter, After\\] work only with properties with one of the following types: \\[class java.time.Instant, class java.time.LocalDate, class java.time.LocalDateTime, class java.time.OffsetTime, class java.time.ZonedDateTime\\]."); |
| 125 | + assertThatExceptionOfType(QueryCreationException.class).isThrownBy(() -> repositoryFactory.getRepository(InvalidTemporal.class)) |
| 126 | + .withMessageMatching("Could not create query for .*: The keywords \\[IsAfter, After] work only with properties with one of the following types: \\[class java.time.Instant, class java.time.LocalDate, class java.time.LocalDateTime, class java.time.OffsetTime, class java.time.ZonedDateTime\\]."); |
126 | 127 | }
|
127 | 128 |
|
128 | 129 | @Test
|
129 | 130 | void validateCollectionShouldWork() {
|
130 | 131 |
|
131 |
| - assertThatIllegalArgumentException().isThrownBy(() -> repositoryFactory.getRepository(InvalidCollection.class)) |
132 |
| - .withMessageMatching("Can not derive query for '.*': The keywords \\[IsEmpty, Empty\\] work only with collection properties."); |
| 132 | + assertThatExceptionOfType(QueryCreationException.class).isThrownBy(() -> repositoryFactory.getRepository(InvalidCollection.class)) |
| 133 | + .withMessageMatching("Could not create query for .*: The keywords \\[IsEmpty, Empty] work only with collection properties."); |
133 | 134 | }
|
134 | 135 |
|
135 | 136 | @Test
|
136 | 137 | void validateSpatialShouldWork() {
|
137 | 138 |
|
138 |
| - assertThatIllegalArgumentException().isThrownBy(() -> repositoryFactory.getRepository(InvalidSpatial.class)) |
139 |
| - .withMessageMatching("Can not derive query for '.*': NEAR \\(1\\): \\[IsNear, Near\\] works only with spatial properties."); |
| 139 | + assertThatExceptionOfType(QueryCreationException.class).isThrownBy(() -> repositoryFactory.getRepository(InvalidSpatial.class)) |
| 140 | + .withMessageMatching("Could not create query for .* \\[IsNear, Near] works only with spatial properties."); |
140 | 141 | }
|
141 | 142 |
|
142 | 143 | @Test
|
143 | 144 | void validateNotACompositePropertyShouldWork() {
|
144 | 145 |
|
145 |
| - assertThatIllegalArgumentException().isThrownBy(() -> repositoryFactory.getRepository(DerivedWithComposite.class)) |
146 |
| - .withMessageMatching("Can not derive query for '.*': Derived queries are not supported for composite properties."); |
| 146 | + assertThatExceptionOfType(QueryCreationException.class).isThrownBy(() -> repositoryFactory.getRepository(DerivedWithComposite.class)) |
| 147 | + .withMessageMatching("Could not create query for .*: Derived queries are not supported for composite properties."); |
147 | 148 | }
|
148 | 149 | }
|
149 | 150 |
|
|
0 commit comments