diff --git a/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java b/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java index 4d9655a9..bc162d9e 100644 --- a/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java +++ b/jpa/query-by-example/src/test/java/example/springdata/jpa/querybyexample/UserRepositoryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,9 @@ */ package example.springdata.jpa.querybyexample; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; -import static org.springframework.data.domain.ExampleMatcher.*; +import static org.assertj.core.api.Assertions.*; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.*; -import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith; +import static org.springframework.data.domain.ExampleMatcher.*; import org.junit.Before; import org.junit.Test; @@ -27,7 +25,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.Example; -import org.springframework.data.domain.ExampleMatcher.StringMatcher; +import org.springframework.data.domain.ExampleMatcher.*; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; @@ -36,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional; * * @author Mark Paluch * @author Oliver Gierke + * @author Jens Schauder */ @SuppressWarnings("unused") @RunWith(SpringRunner.class) @@ -67,7 +66,7 @@ public class UserRepositoryIntegrationTests { Example example = Example.of(new User(null, "White", null)); - assertThat(repository.count(example), is(3L)); + assertThat(repository.count(example)).isEqualTo(3L); } /** @@ -79,7 +78,7 @@ public class UserRepositoryIntegrationTests { Example example = Example.of(flynn, matching().// withIgnorePaths("firstname", "lastname")); - assertThat(repository.findOne(example), is(flynn)); + assertThat(repository.findOne(example)).contains(flynn); } /** @@ -91,7 +90,7 @@ public class UserRepositoryIntegrationTests { Example example = Example.of(new User("er", null, null), matching().// withStringMatcher(StringMatcher.ENDING)); - assertThat(repository.findAll(example), hasItems(skyler, walter)); + assertThat(repository.findAll(example)).containsExactly(skyler, walter); } /** @@ -106,7 +105,7 @@ public class UserRepositoryIntegrationTests { withMatcher("firstname", startsWith()).// withMatcher("lastname", ignoreCase())); - assertThat(repository.findAll(example), hasItems(flynn, walter)); + assertThat(repository.findAll(example)).containsExactlyInAnyOrder(flynn, walter); } /** @@ -121,7 +120,7 @@ public class UserRepositoryIntegrationTests { withMatcher("firstname", matcher -> matcher.startsWith()).// withMatcher("lastname", matcher -> matcher.ignoreCase())); - assertThat(repository.findAll(example), hasItems(flynn, walter)); + assertThat(repository.findAll(example)).containsExactlyInAnyOrder(flynn, walter); } /** @@ -133,6 +132,6 @@ public class UserRepositoryIntegrationTests { Example example = Example.of(new User(null, "White", 99), matching(). // withMatcher("age", matcher -> matcher.transform(value -> Integer.valueOf(50)))); - assertThat(repository.findAll(example), hasItems(walter)); + assertThat(repository.findAll(example)).containsExactly(walter); } }