DATACMNS-867 - First draft.
This commit is contained in:
15
src/test/java/org/springframework/data/domain/AbstractPageRequestUnitTests.java
Normal file → Executable file
15
src/test/java/org/springframework/data/domain/AbstractPageRequestUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.domain.UnitTestUtils.*;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -43,15 +42,15 @@ public abstract class AbstractPageRequestUnitTests {
|
||||
|
||||
Pageable request = newPageRequest(1, 10);
|
||||
|
||||
assertThat(request.hasPrevious(), is(true));
|
||||
assertThat(request.next(), is((Pageable) newPageRequest(2, 10)));
|
||||
assertThat(request.hasPrevious()).isTrue();
|
||||
assertThat(request.next()).isEqualTo((Pageable) newPageRequest(2, 10));
|
||||
|
||||
Pageable first = request.previousOrFirst();
|
||||
|
||||
assertThat(first.hasPrevious(), is(false));
|
||||
assertThat(first, is((Pageable) newPageRequest(0, 10)));
|
||||
assertThat(first, is(request.first()));
|
||||
assertThat(first.previousOrFirst(), is(first));
|
||||
assertThat(first.hasPrevious()).isFalse();
|
||||
assertThat(first).isEqualTo((Pageable) newPageRequest(0, 10));
|
||||
assertThat(first).isEqualTo(request.first());
|
||||
assertThat(first.previousOrFirst()).isEqualTo(first);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
7
src/test/java/org/springframework/data/domain/DirectionUnitTests.java
Normal file → Executable file
7
src/test/java/org/springframework/data/domain/DirectionUnitTests.java
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
@@ -15,13 +15,12 @@ public class DirectionUnitTests {
|
||||
@Test
|
||||
public void jpaValueMapping() throws Exception {
|
||||
|
||||
assertEquals(Direction.ASC, Direction.fromString("asc"));
|
||||
assertEquals(Direction.DESC, Direction.fromString("desc"));
|
||||
assertThat(Direction.fromString("asc")).isEqualTo(Direction.ASC);
|
||||
assertThat(Direction.fromString("desc")).isEqualTo(Direction.DESC);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsInvalidString() throws Exception {
|
||||
|
||||
Direction.fromString("foo");
|
||||
}
|
||||
}
|
||||
|
||||
65
src/test/java/org/springframework/data/domain/ExampleMatcherUnitTests.java
Normal file → Executable file
65
src/test/java/org/springframework/data/domain/ExampleMatcherUnitTests.java
Normal file → Executable file
@@ -15,14 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.data.domain.ExampleMatcher.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.ExampleMatcher.*;
|
||||
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatcher;
|
||||
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
|
||||
import org.springframework.data.domain.ExampleMatcher.MatcherConfigurer;
|
||||
import org.springframework.data.domain.ExampleMatcher.NullHandler;
|
||||
import org.springframework.data.domain.ExampleMatcher.StringMatcher;
|
||||
|
||||
/**
|
||||
* Unit test for {@link ExampleMatcher}.
|
||||
@@ -42,22 +45,22 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void defaultStringMatcherShouldReturnDefault() throws Exception {
|
||||
assertThat(matcher.getDefaultStringMatcher(), is(StringMatcher.DEFAULT));
|
||||
assertThat(matcher.getDefaultStringMatcher()).isEqualTo(StringMatcher.DEFAULT);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoreCaseShouldReturnFalseByDefault() throws Exception {
|
||||
assertThat(matcher.isIgnoreCaseEnabled(), is(false));
|
||||
assertThat(matcher.isIgnoreCaseEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoredPathsIsEmptyByDefault() throws Exception {
|
||||
assertThat(matcher.getIgnoredPaths(), is(empty()));
|
||||
assertThat(matcher.getIgnoredPaths()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void nullHandlerShouldReturnIgnoreByDefault() throws Exception {
|
||||
assertThat(matcher.getNullHandler(), is(NullHandler.IGNORE));
|
||||
assertThat(matcher.getNullHandler()).isEqualTo(NullHandler.IGNORE);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class) // DATACMNS-810
|
||||
@@ -70,7 +73,7 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
matcher = matching().withIgnoreCase();
|
||||
|
||||
assertThat(matcher.isIgnoreCaseEnabled(), is(true));
|
||||
assertThat(matcher.isIgnoreCaseEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
@@ -78,7 +81,7 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
matcher = matching().withIgnoreCase(true);
|
||||
|
||||
assertThat(matcher.isIgnoreCaseEnabled(), is(true));
|
||||
assertThat(matcher.isIgnoreCaseEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
@@ -86,7 +89,7 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
matcher = matching().withIncludeNullValues();
|
||||
|
||||
assertThat(matcher.getNullHandler(), is(NullHandler.INCLUDE));
|
||||
assertThat(matcher.getNullHandler()).isEqualTo(NullHandler.INCLUDE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
@@ -94,7 +97,7 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
matcher = matching().withIgnoreNullValues();
|
||||
|
||||
assertThat(matcher.getNullHandler(), is(NullHandler.IGNORE));
|
||||
assertThat(matcher.getNullHandler()).isEqualTo(NullHandler.IGNORE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
@@ -102,7 +105,7 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
matcher = matching().withNullHandler(NullHandler.INCLUDE);
|
||||
|
||||
assertThat(matcher.getNullHandler(), is(NullHandler.INCLUDE));
|
||||
assertThat(matcher.getNullHandler()).isEqualTo(NullHandler.INCLUDE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
@@ -110,8 +113,8 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
matcher = matching().withIgnorePaths("foo", "bar", "baz");
|
||||
|
||||
assertThat(matcher.getIgnoredPaths(), contains("foo", "bar", "baz"));
|
||||
assertThat(matcher.getIgnoredPaths(), hasSize(3));
|
||||
assertThat(matcher.getIgnoredPaths()).contains("foo", "bar", "baz");
|
||||
assertThat(matcher.getIgnoredPaths()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
@@ -119,8 +122,8 @@ public class ExampleMatcherUnitTests {
|
||||
|
||||
matcher = matching().withIgnorePaths("foo", "bar", "foo");
|
||||
|
||||
assertThat(matcher.getIgnoredPaths(), contains("foo", "bar"));
|
||||
assertThat(matcher.getIgnoredPaths(), hasSize(2));
|
||||
assertThat(matcher.getIgnoredPaths()).contains("foo", "bar");
|
||||
assertThat(matcher.getIgnoredPaths()).hasSize(2);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
@@ -129,33 +132,33 @@ public class ExampleMatcherUnitTests {
|
||||
matcher = matching().withIgnorePaths("foo", "bar", "foo");
|
||||
ExampleMatcher configuredExampleSpec = matcher.withIgnoreCase();
|
||||
|
||||
assertThat(matcher, is(not(sameInstance(configuredExampleSpec))));
|
||||
assertThat(matcher.getIgnoredPaths(), hasSize(2));
|
||||
assertThat(matcher.isIgnoreCaseEnabled(), is(false));
|
||||
assertThat(matcher).isNotEqualTo(sameInstance(configuredExampleSpec));
|
||||
assertThat(matcher.getIgnoredPaths()).hasSize(2);
|
||||
assertThat(matcher.isIgnoreCaseEnabled()).isFalse();
|
||||
|
||||
assertThat(configuredExampleSpec.getIgnoredPaths(), hasSize(2));
|
||||
assertThat(configuredExampleSpec.isIgnoreCaseEnabled(), is(true));
|
||||
assertThat(configuredExampleSpec.getIgnoredPaths()).hasSize(2);
|
||||
assertThat(configuredExampleSpec.isIgnoreCaseEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-879
|
||||
public void defaultMatcherRequiresAllMatching() {
|
||||
|
||||
assertThat(matching().isAllMatching(), is(true));
|
||||
assertThat(matching().isAnyMatching(), is(false));
|
||||
assertThat(matching().isAllMatching()).isTrue();
|
||||
assertThat(matching().isAnyMatching()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-879
|
||||
public void allMatcherRequiresAllMatching() {
|
||||
|
||||
assertThat(matchingAll().isAllMatching(), is(true));
|
||||
assertThat(matchingAll().isAnyMatching(), is(false));
|
||||
assertThat(matchingAll().isAllMatching()).isTrue();
|
||||
assertThat(matchingAll().isAnyMatching()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-879
|
||||
public void anyMatcherYieldsAnyMatching() {
|
||||
|
||||
assertThat(matchingAny().isAnyMatching(), is(true));
|
||||
assertThat(matchingAny().isAllMatching(), is(false));
|
||||
assertThat(matchingAny().isAnyMatching()).isTrue();
|
||||
assertThat(matchingAny().isAllMatching()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-900
|
||||
@@ -190,10 +193,10 @@ public class ExampleMatcherUnitTests {
|
||||
.withNullHandler(NullHandler.IGNORE) //
|
||||
.withMatcher("hello", GenericPropertyMatchers.contains().ignoreCase());
|
||||
|
||||
assertThat(matcher.hashCode(), is(sameAsMatcher.hashCode()));
|
||||
assertThat(matcher.hashCode(), is(not(different.hashCode())));
|
||||
assertThat(matcher, is(equalTo(sameAsMatcher)));
|
||||
assertThat(matcher, is(not(equalTo(different))));
|
||||
assertThat(matcher.hashCode()).isEqualTo(sameAsMatcher.hashCode());
|
||||
assertThat(matcher.hashCode()).isNotEqualTo(different.hashCode());
|
||||
assertThat(matcher).isEqualTo(sameAsMatcher);
|
||||
assertThat(matcher).isNotEqualTo(different);
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
17
src/test/java/org/springframework/data/domain/ExampleUnitTests.java
Normal file → Executable file
17
src/test/java/org/springframework/data/domain/ExampleUnitTests.java
Normal file → Executable file
@@ -15,13 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.domain.ExampleMatcher.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.ExampleMatcher.*;
|
||||
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
|
||||
|
||||
/**
|
||||
* Test for {@link Example}.
|
||||
@@ -50,8 +49,8 @@ public class ExampleUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void returnsSampleObjectsClassAsProbeType() {
|
||||
assertThat(example.getProbeType(), is(equalTo(Person.class)));
|
||||
public void retunsSampleObjectsClassAsProbeType() {
|
||||
assertThat(example.getProbeType()).isEqualTo(Person.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-900
|
||||
@@ -63,10 +62,10 @@ public class ExampleUnitTests {
|
||||
Example<Person> different = Example.of(person,
|
||||
matching().withMatcher("firstname", GenericPropertyMatchers.contains()));
|
||||
|
||||
assertThat(example.hashCode(), is(sameAsExample.hashCode()));
|
||||
assertThat(example.hashCode(), is(not(different.hashCode())));
|
||||
assertThat(example, is(equalTo(sameAsExample)));
|
||||
assertThat(example, is(not(equalTo(different))));
|
||||
assertThat(example.hashCode()).isEqualTo(sameAsExample.hashCode());
|
||||
assertThat(example.hashCode()).isNotEqualTo(different.hashCode());
|
||||
assertThat(example).isEqualTo(sameAsExample);
|
||||
assertThat(example).isNotEqualTo(different);
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
79
src/test/java/org/springframework/data/domain/PageImplUnitTests.java
Normal file → Executable file
79
src/test/java/org/springframework/data/domain/PageImplUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.domain.UnitTestUtils.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -72,13 +71,13 @@ public class PageImplUnitTests {
|
||||
|
||||
Page<Object> page = new PageImpl<Object>(Arrays.asList(new Object()), new PageRequest(0, 1), 10);
|
||||
|
||||
assertThat(page.isFirst(), is(true));
|
||||
assertThat(page.hasPrevious(), is(false));
|
||||
assertThat(page.previousPageable(), is(nullValue()));
|
||||
assertThat(page.isFirst()).isTrue();
|
||||
assertThat(page.hasPrevious()).isFalse();
|
||||
assertThat(page.previousPageable()).isNull();
|
||||
|
||||
assertThat(page.isLast(), is(false));
|
||||
assertThat(page.hasNext(), is(true));
|
||||
assertThat(page.nextPageable(), is((Pageable) new PageRequest(1, 1)));
|
||||
assertThat(page.isLast()).isFalse();
|
||||
assertThat(page.hasNext()).isTrue();
|
||||
assertThat(page.nextPageable()).isEqualTo((Pageable) new PageRequest(1, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,13 +85,13 @@ public class PageImplUnitTests {
|
||||
|
||||
Page<Object> page = new PageImpl<Object>(Arrays.asList(new Object()), new PageRequest(1, 1), 2);
|
||||
|
||||
assertThat(page.isFirst(), is(false));
|
||||
assertThat(page.hasPrevious(), is(true));
|
||||
assertThat(page.previousPageable(), is((Pageable) new PageRequest(0, 1)));
|
||||
assertThat(page.isFirst()).isFalse();
|
||||
assertThat(page.hasPrevious()).isTrue();
|
||||
assertThat(page.previousPageable()).isEqualTo((Pageable) new PageRequest(0, 1));
|
||||
|
||||
assertThat(page.isLast(), is(true));
|
||||
assertThat(page.hasNext(), is(false));
|
||||
assertThat(page.nextPageable(), is(nullValue()));
|
||||
assertThat(page.isLast()).isTrue();
|
||||
assertThat(page.hasNext()).isFalse();
|
||||
assertThat(page.nextPageable()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,18 +100,18 @@ public class PageImplUnitTests {
|
||||
List<String> list = Collections.emptyList();
|
||||
Page<String> page = new PageImpl<String>(list);
|
||||
|
||||
assertThat(page.getContent(), is(list));
|
||||
assertThat(page.getNumber(), is(0));
|
||||
assertThat(page.getNumberOfElements(), is(0));
|
||||
assertThat(page.getSize(), is(0));
|
||||
assertThat(page.getSort(), is((Sort) null));
|
||||
assertThat(page.getTotalElements(), is(0L));
|
||||
assertThat(page.getTotalPages(), is(1));
|
||||
assertThat(page.hasNext(), is(false));
|
||||
assertThat(page.hasPrevious(), is(false));
|
||||
assertThat(page.isFirst(), is(true));
|
||||
assertThat(page.isLast(), is(true));
|
||||
assertThat(page.hasContent(), is(false));
|
||||
assertThat(page.getContent()).isEqualTo(list);
|
||||
assertThat(page.getNumber()).isEqualTo(0);
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(0);
|
||||
assertThat(page.getSize()).isEqualTo(0);
|
||||
assertThat(page.getSort()).isEqualTo((Sort) null);
|
||||
assertThat(page.getTotalElements()).isEqualTo(0L);
|
||||
assertThat(page.getTotalPages()).isEqualTo(1);
|
||||
assertThat(page.hasNext()).isFalse();
|
||||
assertThat(page.hasPrevious()).isFalse();
|
||||
assertThat(page.isFirst()).isTrue();
|
||||
assertThat(page.isLast()).isTrue();
|
||||
assertThat(page.hasContent()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-323
|
||||
@@ -120,9 +119,9 @@ public class PageImplUnitTests {
|
||||
|
||||
Page<String> page = new PageImpl<String>(Arrays.asList("a"));
|
||||
|
||||
assertThat(page.getTotalPages(), is(1));
|
||||
assertThat(page.hasNext(), is(false));
|
||||
assertThat(page.hasPrevious(), is(false));
|
||||
assertThat(page.getTotalPages()).isEqualTo(1);
|
||||
assertThat(page.hasNext()).isFalse();
|
||||
assertThat(page.hasPrevious()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-635
|
||||
@@ -136,36 +135,38 @@ public class PageImplUnitTests {
|
||||
}
|
||||
});
|
||||
|
||||
assertThat(transformed.getContent(), hasSize(2));
|
||||
assertThat(transformed.getContent(), contains(3, 3));
|
||||
assertThat(transformed.getContent()).hasSize(2);
|
||||
assertThat(transformed.getContent()).contains(3, 3);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-713
|
||||
public void adaptsTotalForLastPageOnIntermediateDeletion() {
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(0, 5), 3).getTotalElements(), is(2L));
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(0, 5), 3).getTotalElements())
|
||||
.isEqualTo(2L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-713
|
||||
public void adaptsTotalForLastPageOnIntermediateInsertion() {
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(0, 5), 1).getTotalElements(), is(2L));
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(0, 5), 1).getTotalElements())
|
||||
.isEqualTo(2L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-713
|
||||
public void adaptsTotalForLastPageOnIntermediateDeletionOnLastPate() {
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(1, 10), 13).getTotalElements(),
|
||||
is(12L));
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(1, 10), 13).getTotalElements())
|
||||
.isEqualTo(12L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-713
|
||||
public void adaptsTotalForLastPageOnIntermediateInsertionOnLastPate() {
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(1, 10), 11).getTotalElements(),
|
||||
is(12L));
|
||||
assertThat(new PageImpl<String>(Arrays.asList("foo", "bar"), new PageRequest(1, 10), 11).getTotalElements())
|
||||
.isEqualTo(12L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-713
|
||||
public void doesNotAdapttotalIfPageIsEmpty() {
|
||||
|
||||
assertThat(new PageImpl<String>(Collections.<String> emptyList(), new PageRequest(1, 10), 0).getTotalElements(),
|
||||
is(0L));
|
||||
assertThat(new PageImpl<String>(Collections.<String> emptyList(), new PageRequest(1, 10), 0).getTotalElements())
|
||||
.isEqualTo(0L);
|
||||
}
|
||||
}
|
||||
|
||||
0
src/test/java/org/springframework/data/domain/PageRequestUnitTests.java
Normal file → Executable file
0
src/test/java/org/springframework/data/domain/PageRequestUnitTests.java
Normal file → Executable file
53
src/test/java/org/springframework/data/domain/RangeUnitTests.java
Normal file → Executable file
53
src/test/java/org/springframework/data/domain/RangeUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -38,11 +37,11 @@ public class RangeUnitTests {
|
||||
|
||||
Range<Long> range = new Range<Long>(10L, 20L);
|
||||
|
||||
assertThat(range.contains(10L), is(true));
|
||||
assertThat(range.contains(20L), is(true));
|
||||
assertThat(range.contains(15L), is(true));
|
||||
assertThat(range.contains(5L), is(false));
|
||||
assertThat(range.contains(25L), is(false));
|
||||
assertThat(range.contains(10L)).isTrue();
|
||||
assertThat(range.contains(20L)).isTrue();
|
||||
assertThat(range.contains(15L)).isTrue();
|
||||
assertThat(range.contains(5L)).isFalse();
|
||||
assertThat(range.contains(25L)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
@@ -50,11 +49,11 @@ public class RangeUnitTests {
|
||||
|
||||
Range<Long> range = new Range<Long>(10L, 20L, false, true);
|
||||
|
||||
assertThat(range.contains(10L), is(false));
|
||||
assertThat(range.contains(20L), is(true));
|
||||
assertThat(range.contains(15L), is(true));
|
||||
assertThat(range.contains(5L), is(false));
|
||||
assertThat(range.contains(25L), is(false));
|
||||
assertThat(range.contains(10L)).isFalse();
|
||||
assertThat(range.contains(20L)).isTrue();
|
||||
assertThat(range.contains(15L)).isTrue();
|
||||
assertThat(range.contains(5L)).isFalse();
|
||||
assertThat(range.contains(25L)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
@@ -62,11 +61,11 @@ public class RangeUnitTests {
|
||||
|
||||
Range<Long> range = new Range<Long>(10L, 20L, true, false);
|
||||
|
||||
assertThat(range.contains(10L), is(true));
|
||||
assertThat(range.contains(20L), is(false));
|
||||
assertThat(range.contains(15L), is(true));
|
||||
assertThat(range.contains(5L), is(false));
|
||||
assertThat(range.contains(25L), is(false));
|
||||
assertThat(range.contains(10L)).isTrue();
|
||||
assertThat(range.contains(20L)).isFalse();
|
||||
assertThat(range.contains(15L)).isTrue();
|
||||
assertThat(range.contains(5L)).isFalse();
|
||||
assertThat(range.contains(25L)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
@@ -74,11 +73,11 @@ public class RangeUnitTests {
|
||||
|
||||
Range<Long> range = new Range<Long>(10L, null);
|
||||
|
||||
assertThat(range.contains(10L), is(true));
|
||||
assertThat(range.contains(20L), is(true));
|
||||
assertThat(range.contains(15L), is(true));
|
||||
assertThat(range.contains(5L), is(false));
|
||||
assertThat(range.contains(25L), is(true));
|
||||
assertThat(range.contains(10L)).isTrue();
|
||||
assertThat(range.contains(20L)).isTrue();
|
||||
assertThat(range.contains(15L)).isTrue();
|
||||
assertThat(range.contains(5L)).isFalse();
|
||||
assertThat(range.contains(25L)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-651
|
||||
@@ -86,10 +85,10 @@ public class RangeUnitTests {
|
||||
|
||||
Range<Long> range = new Range<Long>(null, 20L);
|
||||
|
||||
assertThat(range.contains(10L), is(true));
|
||||
assertThat(range.contains(20L), is(true));
|
||||
assertThat(range.contains(15L), is(true));
|
||||
assertThat(range.contains(5L), is(true));
|
||||
assertThat(range.contains(25L), is(false));
|
||||
assertThat(range.contains(10L)).isTrue();
|
||||
assertThat(range.contains(20L)).isTrue();
|
||||
assertThat(range.contains(15L)).isTrue();
|
||||
assertThat(range.contains(5L)).isTrue();
|
||||
assertThat(range.contains(25L)).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
27
src/test/java/org/springframework/data/domain/SortUnitTests.java
Normal file → Executable file
27
src/test/java/org/springframework/data/domain/SortUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.domain.Sort.NullHandling.*;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -40,8 +39,8 @@ public class SortUnitTests {
|
||||
@Test
|
||||
public void appliesDefaultForOrder() throws Exception {
|
||||
|
||||
assertEquals(Sort.DEFAULT_DIRECTION, new Sort("foo").iterator().next().getDirection());
|
||||
assertEquals(Sort.DEFAULT_DIRECTION, new Sort((Direction) null, "foo").iterator().next().getDirection());
|
||||
assertThat(new Sort("foo").iterator().next().getDirection()).isEqualTo(Sort.DEFAULT_DIRECTION);
|
||||
assertThat(new Sort((Direction) null, "foo").iterator().next().getDirection()).isEqualTo(Sort.DEFAULT_DIRECTION);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,24 +91,24 @@ public class SortUnitTests {
|
||||
public void allowsCombiningSorts() {
|
||||
|
||||
Sort sort = new Sort("foo").and(new Sort("bar"));
|
||||
assertThat(sort, hasItems(new Sort.Order("foo"), new Sort.Order("bar")));
|
||||
assertThat(sort).containsExactly(new Sort.Order("foo"), new Sort.Order("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlesAdditionalNullSort() {
|
||||
|
||||
Sort sort = new Sort("foo").and(null);
|
||||
assertThat(sort, hasItem(new Sort.Order("foo")));
|
||||
assertThat(sort).containsExactly(new Sort.Order("foo"));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-281
|
||||
public void configuresIgnoreCaseForOrder() {
|
||||
assertThat(new Order(Direction.ASC, "foo").ignoreCase().isIgnoreCase(), is(true));
|
||||
assertThat(new Order(Direction.ASC, "foo").ignoreCase().isIgnoreCase()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-281
|
||||
public void orderDoesNotIgnoreCaseByDefault() {
|
||||
assertThat(new Order(Direction.ASC, "foo").isIgnoreCase(), is(false));
|
||||
assertThat(new Order(Direction.ASC, "foo").isIgnoreCase()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-436
|
||||
@@ -118,28 +117,28 @@ public class SortUnitTests {
|
||||
Order foo = new Order("foo");
|
||||
Order fooIgnoreCase = new Order("foo").ignoreCase();
|
||||
|
||||
assertThat(foo, is(not(fooIgnoreCase)));
|
||||
assertThat(foo.hashCode(), is(not(fooIgnoreCase.hashCode())));
|
||||
assertThat(foo).isNotEqualTo(fooIgnoreCase);
|
||||
assertThat(foo.hashCode()).isNotEqualTo(fooIgnoreCase.hashCode());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-491
|
||||
public void orderWithNullHandlingHintNullsFirst() {
|
||||
assertThat(new Order("foo").nullsFirst().getNullHandling(), is(NULLS_FIRST));
|
||||
assertThat(new Order("foo").nullsFirst().getNullHandling()).isEqualTo(NULLS_FIRST);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-491
|
||||
public void orderWithNullHandlingHintNullsLast() {
|
||||
assertThat(new Order("foo").nullsLast().getNullHandling(), is(NULLS_LAST));
|
||||
assertThat(new Order("foo").nullsLast().getNullHandling()).isEqualTo(NULLS_LAST);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-491
|
||||
public void orderWithNullHandlingHintNullsNative() {
|
||||
assertThat(new Order("foo").nullsNative().getNullHandling(), is(NATIVE));
|
||||
assertThat(new Order("foo").nullsNative().getNullHandling()).isEqualTo(NATIVE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-491
|
||||
public void orderWithDefaultNullHandlingHint() {
|
||||
assertThat(new Order("foo").getNullHandling(), is(NATIVE));
|
||||
assertThat(new Order("foo").getNullHandling()).isEqualTo(NATIVE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-908
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
@@ -19,9 +19,9 @@ public abstract class UnitTestUtils {
|
||||
*/
|
||||
public static void assertEqualsAndHashcode(Object first, Object second) {
|
||||
|
||||
assertEquals(first, second);
|
||||
assertEquals(second, first);
|
||||
assertEquals(first.hashCode(), second.hashCode());
|
||||
assertThat(first).isEqualTo(second);
|
||||
assertThat(second).isEqualTo(first);
|
||||
assertThat(first.hashCode()).isEqualTo(second.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,8 +32,8 @@ public abstract class UnitTestUtils {
|
||||
*/
|
||||
public static void assertNotEqualsAndHashcode(Object first, Object second) {
|
||||
|
||||
assertFalse(first.equals(second));
|
||||
assertFalse(second.equals(first));
|
||||
assertFalse(first.hashCode() == second.hashCode());
|
||||
assertThat(first).isNotEqualTo(second);
|
||||
assertThat(second).isNotEqualTo(first);
|
||||
assertThat(first.hashCode()).isNotEqualTo(second.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
11
src/test/java/org/springframework/data/domain/jaxb/SpringDataJaxbUnitTests.java
Normal file → Executable file
11
src/test/java/org/springframework/data/domain/jaxb/SpringDataJaxbUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.domain.jaxb;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
@@ -85,7 +84,7 @@ public class SpringDataJaxbUnitTests {
|
||||
wrapper.pageableWithoutSort = new PageRequest(10, 20);
|
||||
marshaller.marshal(wrapper, writer);
|
||||
|
||||
assertThat(new Diff(reference, writer.toString()).similar(), is(true));
|
||||
assertThat(new Diff(reference, writer.toString()).similar()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,9 +92,9 @@ public class SpringDataJaxbUnitTests {
|
||||
|
||||
Object result = unmarshaller.unmarshal(resource.getFile());
|
||||
|
||||
assertThat(result, is(instanceOf(Wrapper.class)));
|
||||
assertThat(((Wrapper) result).pageable, is(pageable));
|
||||
assertThat(((Wrapper) result).sort, is(sort));
|
||||
assertThat(result).isInstanceOf(Wrapper.class);
|
||||
assertThat(((Wrapper) result).pageable).isEqualTo(pageable);
|
||||
assertThat(((Wrapper) result).sort).isEqualTo(sort);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user