Skip to content

Commit e3e5aea

Browse files
committed
Align exception test to commons update.
1 parent b27e13d commit e3e5aea

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.neo4j.repository.support;
1717

18-
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
18+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
1919
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2020
import static org.mockito.Mockito.doReturn;
2121
import static org.mockito.Mockito.mock;
@@ -42,6 +42,7 @@
4242
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCompositeProperties;
4343
import org.springframework.data.neo4j.repository.Neo4jRepository;
4444
import org.springframework.data.repository.core.RepositoryInformation;
45+
import org.springframework.data.repository.query.QueryCreationException;
4546

4647
/**
4748
* @author Gerrit Meier
@@ -114,36 +115,36 @@ void prepareContext() {
114115
void validateIgnoreCaseShouldWork() {
115116

116117

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\\].");
119120
}
120121

121122
@Test
122123
void validateTemporalShouldWork() {
123124

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\\].");
126127
}
127128

128129
@Test
129130
void validateCollectionShouldWork() {
130131

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.");
133134
}
134135

135136
@Test
136137
void validateSpatialShouldWork() {
137138

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.");
140141
}
141142

142143
@Test
143144
void validateNotACompositePropertyShouldWork() {
144145

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.");
147148
}
148149
}
149150

0 commit comments

Comments
 (0)