Switch MongoDB samples to records.

See #606.
This commit is contained in:
Mark Paluch
2021-04-28 15:18:59 +02:00
parent b44dc3dea1
commit e565f33872
69 changed files with 395 additions and 555 deletions

View File

@@ -68,7 +68,7 @@ public class ContactRepositoryIntegrationTests {
@Test
public void countByConcreteSubtypeExample() {
Example<Person> example = Example.of(new Person(null, null, null));
var example = Example.of(new Person(null, null, null));
assertThat(userRepository.count(example), is(3L));
}
@@ -79,7 +79,7 @@ public class ContactRepositoryIntegrationTests {
@Test
public void findAllPersonsBySimpleExample() {
Example<Person> example = Example.of(new Person(".*", null, null), //
var example = Example.of(new Person(".*", null, null), //
matching().withStringMatcher(StringMatcher.REGEX));
assertThat(userRepository.findAll(example), containsInAnyOrder(skyler, walter, flynn));
@@ -92,7 +92,7 @@ public class ContactRepositoryIntegrationTests {
@Test
public void findAllRelativesBySimpleExample() {
Example<Relative> example = Example.of(new Relative(".*", null, null), //
var example = Example.of(new Relative(".*", null, null), //
matching().withStringMatcher(StringMatcher.REGEX));
assertThat(contactRepository.findAll(example), containsInAnyOrder(hank, marie));

View File

@@ -76,7 +76,7 @@ public class MongoOperationsIntegrationTests {
@Test
public void ignoreNullProperties() {
Query query = query(byExample(new Person(null, null, 17)));
var query = query(byExample(new Person(null, null, 17)));
assertThat(operations.find(query, Person.class), hasItems(flynn));
}
@@ -87,7 +87,7 @@ public class MongoOperationsIntegrationTests {
@Test
public void substringMatching() {
Example<Person> example = Example.of(new Person("er", null, null), matching().//
var example = Example.of(new Person("er", null, null), matching().//
withStringMatcher(StringMatcher.ENDING));
assertThat(operations.find(query(byExample(example)), Person.class), hasItems(skyler, walter));
@@ -99,8 +99,8 @@ public class MongoOperationsIntegrationTests {
@Test
public void regexMatching() {
Example<Person> example = Example.of(new Person("(Skyl|Walt)er", null, null), matching().//
withMatcher("firstname", matcher -> matcher.regex()));
var example = Example.of(new Person("(Skyl|Walt)er", null, null), matching().//
withMatcher("firstname", GenericPropertyMatcher::regex));
assertThat(operations.find(query(byExample(example)), Person.class), hasItems(skyler, walter));
}
@@ -111,7 +111,7 @@ public class MongoOperationsIntegrationTests {
@Test
public void matchStartingStringsIgnoreCase() {
Example<Person> example = Example.of(new Person("Walter", "WHITE", null), matching(). //
var example = Example.of(new Person("Walter", "WHITE", null), matching(). //
withIgnorePaths("age").//
withMatcher("firstname", startsWith()).//
withMatcher("lastname", ignoreCase()));
@@ -125,10 +125,10 @@ public class MongoOperationsIntegrationTests {
@Test
public void configuringMatchersUsingLambdas() {
Example<Person> example = Example.of(new Person("Walter", "WHITE", null), matching().//
var example = Example.of(new Person("Walter", "WHITE", null), matching().//
withIgnorePaths("age"). //
withMatcher("firstname", matcher -> matcher.startsWith()). //
withMatcher("lastname", matcher -> matcher.ignoreCase()));
withMatcher("firstname", GenericPropertyMatcher::startsWith). //
withMatcher("lastname", GenericPropertyMatcher::ignoreCase));
assertThat(operations.find(query(byExample(example)), Person.class), hasItems(flynn, walter));
}
@@ -139,8 +139,8 @@ public class MongoOperationsIntegrationTests {
@Test
public void valueTransformer() {
Example<Person> example = Example.of(new Person(null, "White", 99), matching(). //
withMatcher("age", matcher -> matcher.transform(value -> Optional.of(Integer.valueOf(50)))));
var example = Example.of(new Person(null, "White", 99), matching(). //
withMatcher("age", matcher -> matcher.transform(value -> Optional.of(50))));
assertThat(operations.find(query(byExample(example)), Person.class), hasItems(walter));
}

View File

@@ -64,7 +64,7 @@ public class UserRepositoryIntegrationTests {
@Test
public void countBySimpleExample() {
Example<Person> example = Example.of(new Person(null, "White", null));
var example = Example.of(new Person(null, "White", null));
assertThat(repository.count(example)).isEqualTo(3L);
}
@@ -75,7 +75,7 @@ public class UserRepositoryIntegrationTests {
@Test
public void ignorePropertiesAndMatchByAge() {
Example<Person> example = Example.of(flynn, matching(). //
var example = Example.of(flynn, matching(). //
withIgnorePaths("firstname", "lastname"));
assertThat(repository.findOne(example)).contains(flynn);
@@ -87,7 +87,7 @@ public class UserRepositoryIntegrationTests {
@Test
public void substringMatching() {
Example<Person> example = Example.of(new Person("er", null, null), matching(). //
var example = Example.of(new Person("er", null, null), matching(). //
withStringMatcher(StringMatcher.ENDING));
assertThat(repository.findAll(example)).containsExactlyInAnyOrder(skyler, walter);
@@ -99,8 +99,8 @@ public class UserRepositoryIntegrationTests {
@Test
public void regexMatching() {
Example<Person> example = Example.of(new Person("(Skyl|Walt)er", null, null), matching(). //
withMatcher("firstname", matcher -> matcher.regex()));
var example = Example.of(new Person("(Skyl|Walt)er", null, null), matching(). //
withMatcher("firstname", GenericPropertyMatcher::regex));
assertThat(repository.findAll(example)).contains(skyler, walter);
}
@@ -111,7 +111,7 @@ public class UserRepositoryIntegrationTests {
@Test
public void matchStartingStringsIgnoreCase() {
Example<Person> example = Example.of(new Person("Walter", "WHITE", null), matching(). //
var example = Example.of(new Person("Walter", "WHITE", null), matching(). //
withIgnorePaths("age"). //
withMatcher("firstname", startsWith()). //
withMatcher("lastname", ignoreCase()));
@@ -125,10 +125,10 @@ public class UserRepositoryIntegrationTests {
@Test
public void configuringMatchersUsingLambdas() {
Example<Person> example = Example.of(new Person("Walter", "WHITE", null), matching(). //
var example = Example.of(new Person("Walter", "WHITE", null), matching(). //
withIgnorePaths("age"). //
withMatcher("firstname", matcher -> matcher.startsWith()). //
withMatcher("lastname", matcher -> matcher.ignoreCase()));
withMatcher("firstname", GenericPropertyMatcher::startsWith). //
withMatcher("lastname", GenericPropertyMatcher::ignoreCase));
assertThat(repository.findAll(example)).containsExactlyInAnyOrder(flynn, walter);
}
@@ -139,8 +139,8 @@ public class UserRepositoryIntegrationTests {
@Test
public void valueTransformer() {
Example<Person> example = Example.of(new Person(null, "White", 99), matching(). //
withMatcher("age", matcher -> matcher.transform(value -> Optional.of(Integer.valueOf(50)))));
var example = Example.of(new Person(null, "White", 99), matching(). //
withMatcher("age", matcher -> matcher.transform(value -> Optional.of(50))));
assertThat(repository.findAll(example)).containsExactlyInAnyOrder(walter);
}