DATAKV-159 - Integrate DATACMNS Java 8 upgrade.
Related to: DATACMNS-867
This commit is contained in:
@@ -29,6 +29,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -113,28 +114,28 @@ public class KeyValueTemplateTests {
|
||||
|
||||
operations.insert(source);
|
||||
|
||||
assertThat(operations.findById("one", ClassWithStringId.class), is(source));
|
||||
assertThat(operations.findById("one", ClassWithStringId.class), is(Optional.of(source)));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdShouldReturnObjectWithMatchingIdAndType() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.findById("1", Foo.class), is(FOO_ONE));
|
||||
assertThat(operations.findById("1", Foo.class), is(Optional.of(FOO_ONE)));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdSouldReturnNullIfNoMatchingIdFound() {
|
||||
public void findByIdSouldReturnOptionalEmptyIfNoMatchingIdFound() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.findById("2", Foo.class), nullValue());
|
||||
assertThat(operations.findById("2", Foo.class), is(Optional.empty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdShouldReturnNullIfNoMatchingTypeFound() {
|
||||
public void findByIdShouldReturnOptionalEmptyIfNoMatchingTypeFound() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.findById("1", Bar.class), nullValue());
|
||||
assertThat(operations.findById("1", Bar.class), is(Optional.empty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@@ -163,7 +164,7 @@ public class KeyValueTemplateTests {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.update("1", FOO_TWO);
|
||||
assertThat(operations.findById("1", Foo.class), is(FOO_TWO));
|
||||
assertThat(operations.findById("1", Foo.class), is(Optional.of(FOO_TWO)));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@@ -172,7 +173,7 @@ public class KeyValueTemplateTests {
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.update("1", BAR_ONE);
|
||||
|
||||
assertThat(operations.findById("1", Foo.class), is(FOO_ONE));
|
||||
assertThat(operations.findById("1", Foo.class), is(Optional.of(FOO_ONE)));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@@ -180,7 +181,7 @@ public class KeyValueTemplateTests {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.delete("1", Foo.class);
|
||||
assertThat(operations.findById("1", Foo.class), nullValue());
|
||||
assertThat(operations.findById("1", Foo.class), is(Optional.empty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -167,8 +168,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdShouldReturnNullWhenNoElementsPresent() {
|
||||
assertNull(template.findById("1", Foo.class));
|
||||
public void findByIdShouldReturnOptionalEmptyWhenNoElementsPresent() {
|
||||
assertThat(template.findById("1", Foo.class), is(Optional.empty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@@ -214,7 +215,7 @@ public class KeyValueTemplateUnitTests {
|
||||
template.findInRange(1, 5, Foo.class);
|
||||
|
||||
verify(adapterMock, times(1)).find(captor.capture(), eq(Foo.class.getName()), eq(Foo.class));
|
||||
assertThat(captor.getValue().getOffset(), is(1));
|
||||
assertThat(captor.getValue().getOffset(), is(1L));
|
||||
assertThat(captor.getValue().getRows(), is(5));
|
||||
assertThat(captor.getValue().getCritieria(), nullValue());
|
||||
}
|
||||
@@ -325,7 +326,7 @@ public class KeyValueTemplateUnitTests {
|
||||
public void insertSouldRespectTypeAliasAndFilterNonMatching() {
|
||||
|
||||
template.insert("1", ALIASED);
|
||||
assertThat(template.findById("1", SUBCLASS_OF_ALIASED.getClass()), nullValue());
|
||||
assertThat(template.findById("1", SUBCLASS_OF_ALIASED.getClass()), is(Optional.empty()));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACMNS-525
|
||||
|
||||
@@ -18,7 +18,9 @@ package org.springframework.data.keyvalue.repository;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -91,7 +93,9 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void deleteEntity() {
|
||||
|
||||
Foo one = repo.save(new Foo("one"));
|
||||
Foo one = new Foo("one");
|
||||
one.id = "1";
|
||||
repo.save(one);
|
||||
repo.delete(one);
|
||||
|
||||
verify(opsMock, times(1)).delete(eq(one.getId()), eq(Foo.class));
|
||||
@@ -116,6 +120,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
@Test // DATACMNS-525
|
||||
public void findAllIds() {
|
||||
|
||||
when(opsMock.findById(any(Serializable.class), any(Class.class))).thenReturn(Optional.empty());
|
||||
repo.findAll(Arrays.asList("one", "two", "three"));
|
||||
|
||||
verify(opsMock, times(3)).findById(anyString(), eq(Foo.class));
|
||||
@@ -126,7 +131,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
|
||||
repo.findAll(new PageRequest(10, 15));
|
||||
|
||||
verify(opsMock, times(1)).findInRange(eq(150), eq(15), isNull(Sort.class), eq(Foo.class));
|
||||
verify(opsMock, times(1)).findInRange(eq(150L), eq(15), eq(Sort.unsorted()), eq(Foo.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@@ -135,7 +140,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
Sort sort = new Sort("for", "bar");
|
||||
repo.findAll(new PageRequest(10, 15, sort));
|
||||
|
||||
verify(opsMock, times(1)).findInRange(eq(150), eq(15), eq(sort), eq(Foo.class));
|
||||
verify(opsMock, times(1)).findInRange(eq(150L), eq(15), eq(sort), eq(Foo.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
|
||||
@@ -88,7 +88,7 @@ public class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
KeyValueQuery<?> query = partTreeQuery.prepareQuery(new Object[] { new PageRequest(2, 3) });
|
||||
|
||||
assertThat(query.getOffset(), is(6));
|
||||
assertThat(query.getOffset(), is(6L));
|
||||
assertThat(query.getRows(), is(3));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFa
|
||||
import org.springframework.data.keyvalue.repository.support.QuerydslKeyValueRepository;
|
||||
import org.springframework.data.map.QuerydslKeyValueRepositoryUnitTests.QPersonRepository;
|
||||
import org.springframework.data.querydsl.QSort;
|
||||
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@@ -164,5 +164,5 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
static interface QPersonRepository extends org.springframework.data.map.AbstractRepositoryUnitTests.PersonRepository,
|
||||
QueryDslPredicateExecutor<Person> {}
|
||||
QuerydslPredicateExecutor<Person> {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user