#297 - Upgraded to Boot 2.0 and Spring Data Kay.
Bumped version number to 2.0. Upgraded to Spring Boot 2.0. Stuff disabled in the meantime: - Cassandra: needs API adaptions in configuration - JPA > Security: test fails with weird Hibernate error - Redis > Reactive: API updates needed - Solr: configration updates necessary adjust versions Updated elastic search to the new version. Fixed the reactor version to Bismuth-BUILD-SNAPSHOT. This probably should be undone when boot references the proper bom.
This commit is contained in:
@@ -15,18 +15,19 @@
|
||||
*/
|
||||
package example.springdata.jpa.showcase.after;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import example.springdata.jpa.showcase.AbstractShowcaseTest;
|
||||
import example.springdata.jpa.showcase.core.Account;
|
||||
import example.springdata.jpa.showcase.core.Customer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Integration tests for Spring Data JPA {@link AccountRepository}.
|
||||
*
|
||||
@@ -41,16 +42,17 @@ public class AccountRepositoryIntegrationTest extends AbstractShowcaseTest {
|
||||
public void savesAccount() {
|
||||
|
||||
Account account = accountRepository.save(new Account());
|
||||
assertThat(account.getId(), is(notNullValue()));
|
||||
|
||||
assertThat(account.getId()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsCustomersAccounts() {
|
||||
|
||||
Customer customer = customerRepository.findOne(1L);
|
||||
List<Account> accounts = accountRepository.findByCustomer(customer);
|
||||
Optional<Customer> customer = customerRepository.findById(1L);
|
||||
List<Account> accounts = customer.map(accountRepository::findByCustomer).orElse(Collections.emptyList());
|
||||
|
||||
assertFalse(accounts.isEmpty());
|
||||
assertThat(accounts.get(0).getCustomer(), is(customer));
|
||||
assertThat(accounts).isNotEmpty();
|
||||
assertThat(customer).hasValueSatisfying(it -> assertThat(accounts.get(0).getCustomer()).isEqualTo(it));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
package example.springdata.jpa.showcase.after;
|
||||
|
||||
import static example.springdata.jpa.showcase.snippets.CustomerSpecifications.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.jpa.domain.Specifications.*;
|
||||
|
||||
import example.springdata.jpa.showcase.AbstractShowcaseTest;
|
||||
import example.springdata.jpa.showcase.core.Customer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Test;
|
||||
@@ -28,9 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import example.springdata.jpa.showcase.AbstractShowcaseTest;
|
||||
import example.springdata.jpa.showcase.core.Customer;
|
||||
|
||||
/**
|
||||
* Integration tests for Spring Data JPA {@link CustomerRepository}.
|
||||
*
|
||||
@@ -42,40 +42,36 @@ public class CustomerRepositoryIntegrationTest extends AbstractShowcaseTest {
|
||||
|
||||
@Test
|
||||
public void findsAllCustomers() throws Exception {
|
||||
|
||||
Iterable<Customer> result = repository.findAll();
|
||||
|
||||
assertThat(result, is(notNullValue()));
|
||||
assertTrue(result.iterator().hasNext());
|
||||
assertThat(repository.findAll()).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsFirstPageOfMatthews() throws Exception {
|
||||
|
||||
Page<Customer> customers = repository.findByLastname("Matthews", new PageRequest(0, 2));
|
||||
Page<Customer> customers = repository.findByLastname("Matthews", PageRequest.of(0, 2));
|
||||
|
||||
assertThat(customers.getContent().size(), is(2));
|
||||
assertFalse(customers.hasPrevious());
|
||||
assertThat(customers.getContent()).hasSize(2);
|
||||
assertThat(customers.hasPrevious()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsCustomerById() throws Exception {
|
||||
|
||||
Customer customer = repository.findOne(2L);
|
||||
|
||||
assertThat(customer.getFirstname(), is("Carter"));
|
||||
assertThat(customer.getLastname(), is("Beauford"));
|
||||
assertThat(repository.findById(2L)).hasValueSatisfying(it -> {
|
||||
assertThat(it.getFirstname()).isEqualTo("Carter");
|
||||
assertThat(it.getLastname()).isEqualTo("Beauford");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsCustomersBySpecification() throws Exception {
|
||||
|
||||
Customer dave = repository.findOne(1L);
|
||||
Optional<Customer> dave = repository.findById(1L);
|
||||
|
||||
LocalDate expiryLimit = new LocalDate(2011, 3, 1);
|
||||
List<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit)));
|
||||
|
||||
assertThat(result.size(), is(1));
|
||||
assertThat(result, hasItems(dave));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(dave).hasValueSatisfying(it -> assertThat(result).contains(it));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user