DATAKV-169 - Polishing.
Fix typo in test method names. Some minor language level cleanups and removal of deprecated API usage. Original pull request: #23.
This commit is contained in:
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.core;
|
||||
|
||||
import static org.hamcrest.core.Is.*;
|
||||
import static org.hamcrest.core.IsNull.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@@ -47,7 +46,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
|
||||
when(iteratorMock.hasNext()).thenReturn(true);
|
||||
|
||||
CloseableIterator<Entry<K, V>> iterator = new ForwardingCloseableIterator<Entry<K, V>>(iteratorMock);
|
||||
CloseableIterator<Entry<K, V>> iterator = new ForwardingCloseableIterator<>(iteratorMock);
|
||||
|
||||
try {
|
||||
assertThat(iterator.hasNext(), is(true));
|
||||
@@ -63,7 +62,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
|
||||
when(iteratorMock.next()).thenReturn((Entry<K, V>) mock(Map.Entry.class));
|
||||
|
||||
CloseableIterator<Entry<K, V>> iterator = new ForwardingCloseableIterator<Entry<K, V>>(iteratorMock);
|
||||
CloseableIterator<Entry<K, V>> iterator = new ForwardingCloseableIterator<>(iteratorMock);
|
||||
|
||||
try {
|
||||
assertThat(iterator.next(), notNullValue());
|
||||
@@ -78,7 +77,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
|
||||
when(iteratorMock.next()).thenThrow(new NoSuchElementException());
|
||||
|
||||
CloseableIterator<Entry<K, V>> iterator = new ForwardingCloseableIterator<Entry<K, V>>(iteratorMock);
|
||||
CloseableIterator<Entry<K, V>> iterator = new ForwardingCloseableIterator<>(iteratorMock);
|
||||
|
||||
try {
|
||||
iterator.next();
|
||||
@@ -90,7 +89,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
@Test // DATAKV-99
|
||||
public void closeShouldDoNothingByDefault() {
|
||||
|
||||
new ForwardingCloseableIterator<Entry<K, V>>(iteratorMock).close();
|
||||
new ForwardingCloseableIterator<>(iteratorMock).close();
|
||||
|
||||
verifyZeroInteractions(iteratorMock);
|
||||
}
|
||||
@@ -98,7 +97,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
@Test // DATAKV-99
|
||||
public void closeShouldInvokeConfiguredCloseAction() {
|
||||
|
||||
new ForwardingCloseableIterator<Entry<K, V>>(iteratorMock, closeActionMock).close();
|
||||
new ForwardingCloseableIterator<>(iteratorMock, closeActionMock).close();
|
||||
|
||||
verify(closeActionMock, times(1)).run();
|
||||
}
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.core;
|
||||
|
||||
import static org.hamcrest.collection.IsEmptyCollection.*;
|
||||
import static org.hamcrest.collection.IsIterableContainingInOrder.*;
|
||||
import static org.hamcrest.core.IsInstanceOf.*;
|
||||
import static org.hamcrest.core.IsNull.*;
|
||||
import static org.hamcrest.core.IsSame.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.data.keyvalue.core.IterableConverter.*;
|
||||
|
||||
@@ -50,7 +46,7 @@ public class IterableConverterUnitTests {
|
||||
@Test // DATAKV-101
|
||||
public void toListShouldReturnSameObjectWhenSourceIsAlreadyListType() {
|
||||
|
||||
List<String> source = new ArrayList<String>();
|
||||
List<String> source = new ArrayList<>();
|
||||
|
||||
assertThat(toList(source), sameInstance(source));
|
||||
}
|
||||
@@ -58,7 +54,7 @@ public class IterableConverterUnitTests {
|
||||
@Test // DATAKV-101
|
||||
public void toListShouldReturnListWhenSourceIsNonListType() {
|
||||
|
||||
Set<String> source = new HashSet<String>();
|
||||
Set<String> source = new HashSet<>();
|
||||
source.add("tyrion");
|
||||
|
||||
assertThat(toList(source), instanceOf(List.class));
|
||||
@@ -67,7 +63,7 @@ public class IterableConverterUnitTests {
|
||||
@Test // DATAKV-101
|
||||
public void toListShouldHoldValuesInOrderOfSource() {
|
||||
|
||||
Set<String> source = new LinkedHashSet<String>();
|
||||
Set<String> source = new LinkedHashSet<>();
|
||||
source.add("tyrion");
|
||||
source.add("jaime");
|
||||
|
||||
|
||||
@@ -15,12 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.core;
|
||||
|
||||
import static org.hamcrest.collection.IsCollectionWithSize.*;
|
||||
import static org.hamcrest.collection.IsEmptyIterable.*;
|
||||
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.*;
|
||||
import static org.hamcrest.core.Is.*;
|
||||
import static org.hamcrest.core.IsNull.*;
|
||||
import static org.hamcrest.core.IsSame.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -54,7 +49,7 @@ public class KeyValueTemplateTests {
|
||||
static final Bar BAR_ONE = new Bar("one");
|
||||
static final ClassWithTypeAlias ALIASED = new ClassWithTypeAlias("super");
|
||||
static final SubclassOfAliasedType SUBCLASS_OF_ALIASED = new SubclassOfAliasedType("sub");
|
||||
static final KeyValueQuery<String> STRING_QUERY = new KeyValueQuery<String>("foo == 'two'");
|
||||
static final KeyValueQuery<String> STRING_QUERY = new KeyValueQuery<>("foo == 'two'");
|
||||
|
||||
KeyValueTemplate operations;
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.core;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
@@ -75,7 +74,7 @@ public class KeyValueTemplateUnitTests {
|
||||
"super");
|
||||
private static final SubclassOfTypeWithCustomComposedKeySpaceAnnotation SUBCLASS_OF_ALIASED = new SubclassOfTypeWithCustomComposedKeySpaceAnnotation(
|
||||
"sub");
|
||||
private static final KeyValueQuery<String> STRING_QUERY = new KeyValueQuery<String>("foo == 'two'");
|
||||
private static final KeyValueQuery<String> STRING_QUERY = new KeyValueQuery<>("foo == 'two'");
|
||||
|
||||
private @Mock KeyValueAdapter adapterMock;
|
||||
private KeyValueTemplate template;
|
||||
@@ -557,7 +556,7 @@ public class KeyValueTemplateUnitTests {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void setEventsToPublish(Class<? extends KeyValueEvent>... events) {
|
||||
template.setEventTypesToPublish(new HashSet<Class<? extends KeyValueEvent>>(Arrays.asList(events)));
|
||||
template.setEventTypesToPublish(new HashSet<>(Arrays.asList(events)));
|
||||
}
|
||||
|
||||
static class Foo {
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SpelPropertyComparator}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ public class SpelPropertyComperatorUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareStringAscCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("stringProperty", PARSER);
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("stringProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, TWO), is(ONE.getStringProperty().compareTo(TWO.getStringProperty())));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SpelPropertyComperatorUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareIntegerAscCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("integerProperty", PARSER);
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("integerProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, TWO), is(ONE.getIntegerProperty().compareTo(TWO.getIntegerProperty())));
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SpelPropertyComperatorUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void shouldComparePrimitiveIntegerAscCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("primitiveProperty", PARSER);
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("primitiveProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, TWO),
|
||||
is(valueOf(ONE.getPrimitiveProperty()).compareTo(valueOf(TWO.getPrimitiveProperty()))));
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class SpelPropertyComperatorUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void shouldNotFailOnNullValues() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("stringProperty", PARSER);
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("stringProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, new SomeType(null, null, 2)), is(1));
|
||||
}
|
||||
|
||||
@@ -107,16 +107,15 @@ public class SpelPropertyComperatorUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareNestedTypesCorrectly() {
|
||||
|
||||
Comparator<WrapperType> comparator = new SpelPropertyComparator<WrapperType>("nestedType.stringProperty", PARSER);
|
||||
assertThat(comparator.compare(WRAPPER_ONE, WRAPPER_TWO), is(WRAPPER_ONE.getNestedType().getStringProperty()
|
||||
.compareTo(WRAPPER_TWO.getNestedType().getStringProperty())));
|
||||
Comparator<WrapperType> comparator = new SpelPropertyComparator<>("nestedType.stringProperty", PARSER);
|
||||
assertThat(comparator.compare(WRAPPER_ONE, WRAPPER_TWO),
|
||||
is(WRAPPER_ONE.getNestedType().getStringProperty().compareTo(WRAPPER_TWO.getNestedType().getStringProperty())));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareNestedTypesCorrectlyWhenOneOfThemHasNullValue() {
|
||||
|
||||
SpelPropertyComparator<WrapperType> comparator = new SpelPropertyComparator<WrapperType>(
|
||||
"nestedType.stringProperty", PARSER);
|
||||
SpelPropertyComparator<WrapperType> comparator = new SpelPropertyComparator<>("nestedType.stringProperty", PARSER);
|
||||
assertThat(comparator.compare(WRAPPER_ONE, new WrapperType("two", null)), is(greaterThanOrEqualTo(1)));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,12 @@ package org.springframework.data.keyvalue.core;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -43,7 +42,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SpelQueryEngine}.
|
||||
*
|
||||
*
|
||||
* @author Martin Macko
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -62,7 +61,7 @@ public class SpelQueryEngineUnitTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
engine = new SpelQueryEngine<KeyValueAdapter>();
|
||||
engine = new SpelQueryEngine<>();
|
||||
engine.registerAdapter(adapter);
|
||||
}
|
||||
|
||||
@@ -72,8 +71,8 @@ public class SpelQueryEngineUnitTests {
|
||||
|
||||
doReturn(people).when(adapter).getAllOf(anyString());
|
||||
|
||||
assertThat((Collection<Person>) engine.execute(createQueryForMethodWithArgs("findByFirstname", "bob"), null, -1,
|
||||
-1, anyString()), contains(BOB_WITH_FIRSTNAME));
|
||||
assertThat(engine.execute(createQueryForMethodWithArgs("findByFirstname", "bob"), null, -1, -1, anyString()),
|
||||
contains(BOB_WITH_FIRSTNAME));
|
||||
}
|
||||
|
||||
@Test // DATAKV-114
|
||||
@@ -86,7 +85,7 @@ public class SpelQueryEngineUnitTests {
|
||||
|
||||
private static SpelCriteria createQueryForMethodWithArgs(String methodName, Object... args) throws Exception {
|
||||
|
||||
List<Class<?>> types = new ArrayList<Class<?>>(args.length);
|
||||
List<Class<?>> types = new ArrayList<>(args.length);
|
||||
|
||||
for (Object arg : args) {
|
||||
types.add(arg.getClass());
|
||||
@@ -97,8 +96,8 @@ public class SpelQueryEngineUnitTests {
|
||||
doReturn(method.getReturnType()).when(metadata).getReturnedDomainClass(method);
|
||||
|
||||
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
|
||||
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(new QueryMethod(method,
|
||||
metadata, new SpelAwareProxyProjectionFactory()).getParameters(), args));
|
||||
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(
|
||||
new QueryMethod(method, metadata, new SpelAwareProxyProjectionFactory()).getParameters(), args));
|
||||
|
||||
return new SpelCriteria(creator.createQuery().getCritieria(), new StandardEvaluationContext(args));
|
||||
}
|
||||
|
||||
@@ -48,17 +48,15 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
ReflectionEntityInformation<Foo, String> ei = new ReflectionEntityInformation<Foo, String>(Foo.class);
|
||||
repo = new SimpleKeyValueRepository<Foo, String>(ei, opsMock);
|
||||
ReflectionEntityInformation<Foo, String> ei = new ReflectionEntityInformation<>(Foo.class);
|
||||
repo = new SimpleKeyValueRepository<>(ei, opsMock);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void saveNewWithNumericId() {
|
||||
|
||||
ReflectionEntityInformation<WithNumericId, Integer> ei = new ReflectionEntityInformation<WithNumericId, Integer>(
|
||||
WithNumericId.class);
|
||||
SimpleKeyValueRepository<WithNumericId, Integer> temp = new SimpleKeyValueRepository<WithNumericId, Integer>(ei,
|
||||
opsMock);
|
||||
ReflectionEntityInformation<WithNumericId, Integer> ei = new ReflectionEntityInformation<>(WithNumericId.class);
|
||||
SimpleKeyValueRepository<WithNumericId, Integer> temp = new SimpleKeyValueRepository<>(ei, opsMock);
|
||||
|
||||
WithNumericId withNumericId = new WithNumericId();
|
||||
temp.save(withNumericId);
|
||||
@@ -129,7 +127,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void findAllWithPageableShouldDelegateToOperationsCorrectlyWhenPageableDoesNotContainSort() {
|
||||
|
||||
repo.findAll(new PageRequest(10, 15));
|
||||
repo.findAll(PageRequest.of(10, 15));
|
||||
|
||||
verify(opsMock, times(1)).findInRange(eq(150L), eq(15), eq(Sort.unsorted()), eq(Foo.class));
|
||||
}
|
||||
@@ -137,8 +135,8 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void findAllWithPageableShouldDelegateToOperationsCorrectlyWhenPageableContainsSort() {
|
||||
|
||||
Sort sort = new Sort("for", "bar");
|
||||
repo.findAll(new PageRequest(10, 15, sort));
|
||||
Sort sort = Sort.by("for", "bar");
|
||||
repo.findAll(PageRequest.of(10, 15, sort));
|
||||
|
||||
verify(opsMock, times(1)).findInRange(eq(150L), eq(15), eq(sort), eq(Foo.class));
|
||||
}
|
||||
|
||||
@@ -15,12 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.repository.query;
|
||||
|
||||
import static org.hamcrest.core.Is.*;
|
||||
import static org.hamcrest.core.IsNot.*;
|
||||
import static org.hamcrest.core.IsNull.*;
|
||||
import static org.hamcrest.core.IsSame.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -86,7 +83,7 @@ public class KeyValuePartTreeQueryUnitTests {
|
||||
KeyValuePartTreeQuery partTreeQuery = new KeyValuePartTreeQuery(qm, DefaultEvaluationContextProvider.INSTANCE,
|
||||
kvOpsMock, SpelQueryCreator.class);
|
||||
|
||||
KeyValueQuery<?> query = partTreeQuery.prepareQuery(new Object[] { new PageRequest(2, 3) });
|
||||
KeyValueQuery<?> query = partTreeQuery.prepareQuery(new Object[] { PageRequest.of(2, 3) });
|
||||
|
||||
assertThat(query.getOffset(), is(6L));
|
||||
assertThat(query.getRows(), is(3));
|
||||
|
||||
@@ -72,32 +72,32 @@ public class SpelQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isTrueAssertedPropertlyWhenTrue() throws Exception {
|
||||
public void isTrueAssertedProperlyWhenTrue() throws Exception {
|
||||
assertThat(evaluate("findBySkinChangerIsTrue").against(BRAN), is(true));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isTrueAssertedPropertlyWhenFalse() throws Exception {
|
||||
public void isTrueAssertedProperlyWhenFalse() throws Exception {
|
||||
assertThat(evaluate("findBySkinChangerIsTrue").against(RICKON), is(false));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isFalseAssertedPropertlyWhenTrue() throws Exception {
|
||||
public void isFalseAssertedProperlyWhenTrue() throws Exception {
|
||||
assertThat(evaluate("findBySkinChangerIsFalse").against(BRAN), is(false));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isFalseAssertedPropertlyWhenFalse() throws Exception {
|
||||
public void isFalseAssertedProperlyWhenFalse() throws Exception {
|
||||
assertThat(evaluate("findBySkinChangerIsFalse").against(RICKON), is(true));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isNullAssertedPropertlyWhenAttributeIsNull() throws Exception {
|
||||
public void isNullAssertedProperlyWhenAttributeIsNull() throws Exception {
|
||||
assertThat(evaluate("findByLastnameIsNull").against(BRAN), is(true));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isNullAssertedPropertlyWhenAttributeIsNotNull() throws Exception {
|
||||
public void isNullAssertedProperlyWhenAttributeIsNotNull() throws Exception {
|
||||
assertThat(evaluate("findByLastnameIsNull").against(ROBB), is(false));
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ public class SpelQueryCreatorUnitTests {
|
||||
SpelExpression expression;
|
||||
Object candidate;
|
||||
|
||||
public Evaluation(SpelExpression expresison) {
|
||||
this.expression = expresison;
|
||||
public Evaluation(SpelExpression expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public Boolean against(Object candidate) {
|
||||
|
||||
@@ -35,7 +35,7 @@ import com.querydsl.core.types.dsl.PathBuilder;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link KeyValueQuerydslUtils}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
@@ -49,12 +49,12 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
public void setUp() {
|
||||
|
||||
this.path = SimpleEntityPathResolver.INSTANCE.createPath(Person.class);
|
||||
this.builder = new PathBuilder<Person>(path.getType(), path.getMetadata());
|
||||
this.builder = new PathBuilder<>(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACMNS-525
|
||||
public void toOrderSpecifierThrowsExceptioOnNullPathBuilder() {
|
||||
toOrderSpecifier(new Sort("firstname"), null);
|
||||
toOrderSpecifier(Sort.by("firstname"), null);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@@ -65,7 +65,7 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSimpleAscSortCorrectly() {
|
||||
|
||||
Sort sort = new Sort(Direction.ASC, "firstname");
|
||||
Sort sort = Sort.by(Direction.ASC, "firstname");
|
||||
|
||||
OrderSpecifier<?>[] specifiers = toOrderSpecifier(sort, builder);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSimpleDescSortCorrectly() {
|
||||
|
||||
Sort sort = new Sort(Direction.DESC, "firstname");
|
||||
Sort sort = Sort.by(Direction.DESC, "firstname");
|
||||
|
||||
OrderSpecifier<?>[] specifiers = toOrderSpecifier(sort, builder);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSortCorrectlyAndRetainsArgumentOrder() {
|
||||
|
||||
Sort sort = new Sort(Direction.DESC, "firstname").and(new Sort(Direction.ASC, "age"));
|
||||
Sort sort = Sort.by(Direction.DESC, "firstname").and(Sort.by(Direction.ASC, "age"));
|
||||
|
||||
OrderSpecifier<?>[] specifiers = toOrderSpecifier(sort, builder);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSortWithNullHandlingCorrectly() {
|
||||
|
||||
Sort sort = new Sort(new Sort.Order(Direction.DESC, "firstname", NullHandling.NULLS_LAST));
|
||||
Sort sort = Sort.by(new Sort.Order(Direction.DESC, "firstname", NullHandling.NULLS_LAST));
|
||||
|
||||
OrderSpecifier<?>[] specifiers = toOrderSpecifier(sort, builder);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
/**
|
||||
* Base class for test cases for repository implementations.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
|
||||
repository.save(LENNISTERS);
|
||||
|
||||
Page<Person> page = repository.findByAge(19, new PageRequest(0, 1));
|
||||
Page<Person> page = repository.findByAge(19, PageRequest.of(0, 1));
|
||||
assertThat(page.hasNext(), is(true));
|
||||
assertThat(page.getTotalElements(), is(2L));
|
||||
assertThat(page.getContent(), IsCollectionWithSize.hasSize(1));
|
||||
@@ -132,7 +132,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
repository.save(LENNISTERS);
|
||||
|
||||
assertThat(
|
||||
repository.findAll(new Sort(new Sort.Order(Direction.ASC, "age"), new Sort.Order(Direction.DESC, "firstname"))),
|
||||
repository.findAll(Sort.by(new Sort.Order(Direction.ASC, "age"), new Sort.Order(Direction.DESC, "firstname"))),
|
||||
contains(TYRION, JAIME, CERSEI));
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
|
||||
repository.save(LENNISTERS);
|
||||
|
||||
List<PersonSummary> result = repository.findByAgeGreaterThan(0, new Sort("firstname"));
|
||||
List<PersonSummary> result = repository.findByAgeGreaterThan(0, Sort.by("firstname"));
|
||||
|
||||
assertThat(result, hasSize(3));
|
||||
assertThat(result.get(0).getFirstname(), is(CERSEI.getFirstname()));
|
||||
@@ -162,7 +162,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
|
||||
repository.save(LENNISTERS);
|
||||
|
||||
List<PersonSummary> result = repository.findByAgeGreaterThan(0, new Sort("firstname"), PersonSummary.class);
|
||||
List<PersonSummary> result = repository.findByAgeGreaterThan(0, Sort.by("firstname"), PersonSummary.class);
|
||||
|
||||
assertThat(result, hasSize(3));
|
||||
assertThat(result.get(0).getFirstname(), is(CERSEI.getFirstname()));
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link QuerydslKeyValueRepository}.
|
||||
*
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
@@ -66,7 +66,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
public void findWithPaginationWorksCorrectly() {
|
||||
|
||||
repository.save(LENNISTERS);
|
||||
Page<Person> page1 = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()), new PageRequest(0, 1));
|
||||
Page<Person> page1 = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()), PageRequest.of(0, 1));
|
||||
|
||||
assertThat(page1.getTotalElements(), is(2L));
|
||||
assertThat(page1.getContent(), hasSize(1));
|
||||
@@ -96,8 +96,8 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
|
||||
repository.save(LENNISTERS);
|
||||
|
||||
Iterable<Person> result = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()), new PageRequest(0, 10,
|
||||
Direction.DESC, "firstname"));
|
||||
Iterable<Person> result = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()),
|
||||
PageRequest.of(0, 10, Direction.DESC, "firstname"));
|
||||
|
||||
assertThat(result, contains(JAIME, CERSEI));
|
||||
}
|
||||
@@ -107,8 +107,8 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
|
||||
repository.save(LENNISTERS);
|
||||
|
||||
Iterable<Person> result = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()), new PageRequest(0, 10,
|
||||
new QSort(QPerson.person.firstname.desc())));
|
||||
Iterable<Person> result = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()),
|
||||
PageRequest.of(0, 10, new QSort(QPerson.person.firstname.desc())));
|
||||
|
||||
assertThat(result, contains(JAIME, CERSEI));
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
|
||||
repository.save(LENNISTERS);
|
||||
|
||||
List<Person> users = Lists.newArrayList(repository.findAll(person.age.gt(0), new Sort(Direction.ASC, "firstname")));
|
||||
List<Person> users = Lists.newArrayList(repository.findAll(person.age.gt(0), Sort.by(Direction.ASC, "firstname")));
|
||||
|
||||
assertThat(users, hasSize(3));
|
||||
assertThat(users.get(0).getFirstname(), is(CERSEI.getFirstname()));
|
||||
@@ -154,7 +154,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
assertThat(users, hasItems(CERSEI, JAIME, TYRION));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.map.SimpleKeyValueRepositoryUnitTests#getRepository(org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactory)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user