Java 16 migration for Map repository examples.

See #606.
This commit is contained in:
Mark Paluch
2021-04-28 10:52:43 +02:00
parent a4c9302780
commit 20dfd398c8
3 changed files with 24 additions and 16 deletions

View File

@@ -13,4 +13,17 @@
<relativePath>../pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -17,9 +17,6 @@ package example.springdata.ldap;
import static org.assertj.core.api.Assertions.*;
import java.util.List;
import java.util.Optional;
import javax.naming.InvalidNameException;
import javax.naming.ldap.LdapName;
@@ -47,7 +44,7 @@ public class PersonRepositoryIntegrationTests {
@Test
void findOneByName() throws InvalidNameException {
Optional<Person> person = personRepository.findById(new LdapName("uid=bob,ou=people,dc=springframework,dc=org"));
var person = personRepository.findById(new LdapName("uid=bob,ou=people,dc=springframework,dc=org"));
assertThat(person).hasValueSatisfying(it -> {
assertThat(it.getFullName()).isEqualTo("Bob Hamilton");
@@ -62,7 +59,7 @@ public class PersonRepositoryIntegrationTests {
@Test
void findAll() {
Iterable<Person> people = personRepository.findAll();
var people = personRepository.findAll();
assertThat(people).hasSize(3).extracting("uid").contains("bob", "joe", "ben");
}
@@ -73,7 +70,7 @@ public class PersonRepositoryIntegrationTests {
@Test
void findByLastname() {
List<Person> people = personRepository.findByLastnameStartsWith("Ham");
var people = personRepository.findByLastnameStartsWith("Ham");
assertThat(people).hasSize(1).extracting("uid").contains("bob");
}
@@ -86,14 +83,14 @@ public class PersonRepositoryIntegrationTests {
@Test
void addUser() throws InvalidNameException {
Person walter = new Person();
var walter = new Person();
walter.setFullName("Walter White");
walter.setUid("heisenberg");
walter.setLastname("White");
personRepository.save(walter);
List<Person> people = personRepository.findByUid("heisenberg");
var people = personRepository.findByUid("heisenberg");
assertThat(people).hasSize(1).extracting("fullName").contains("Walter White");

View File

@@ -17,9 +17,8 @@ package example.springdata.map;
import static org.assertj.core.api.Assertions.*;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
@@ -43,7 +42,7 @@ class PersonRepositoryIntegrationTest {
@Test
void storesPerson() {
Person person = repository.save(new Person("Dave", "Matthews", 47));
var person = repository.save(new Person("Dave", "Matthews", 47));
assertThat(repository.findById(person.getId())).hasValue(person);
}
@@ -51,12 +50,11 @@ class PersonRepositoryIntegrationTest {
@Test
void findsPersonByAge() {
Person dave = repository.save(new Person("Dave", "Matthews", 47));
Person oliver = repository.save(new Person("Oliver August", "Matthews", 7));
var dave = repository.save(new Person("Dave", "Matthews", 47));
var oliver = repository.save(new Person("Oliver August", "Matthews", 7));
List<Person> result = repository.findByAgeGreaterThan(18);
var result = repository.findByAgeGreaterThan(18);
assertThat(result).contains(dave);
assertThat(result).doesNotContain(oliver);
assertThat(result).contains(dave).doesNotContain(oliver);
}
}