DATAKV-332 - Migrate tests to JUnit 5.
This commit is contained in:
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
@@ -28,49 +28,45 @@ import org.springframework.data.util.ClassTypeInformation;
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class DefaultIdentifierGeneratorUnitTests {
|
||||
class DefaultIdentifierGeneratorUnitTests {
|
||||
|
||||
DefaultIdentifierGenerator generator = DefaultIdentifierGenerator.INSTANCE;
|
||||
private DefaultIdentifierGenerator generator = DefaultIdentifierGenerator.INSTANCE;
|
||||
|
||||
@Test
|
||||
public void shouldThrowExceptionForUnsupportedType() {
|
||||
void shouldThrowExceptionForUnsupportedType() {
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
.isThrownBy(() -> generator.generateIdentifierOfType(ClassTypeInformation.from(Date.class)));
|
||||
}
|
||||
|
||||
@Test // DATAKV-136
|
||||
public void shouldGenerateUUIDValueCorrectly() {
|
||||
void shouldGenerateUUIDValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(UUID.class));
|
||||
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value).isInstanceOf(UUID.class);
|
||||
assertThat(value).isNotNull().isInstanceOf(UUID.class);
|
||||
}
|
||||
|
||||
@Test // DATAKV-136
|
||||
public void shouldGenerateStringValueCorrectly() {
|
||||
void shouldGenerateStringValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(String.class));
|
||||
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value).isInstanceOf(String.class);
|
||||
assertThat(value).isNotNull().isInstanceOf(String.class);
|
||||
}
|
||||
|
||||
@Test // DATAKV-136
|
||||
public void shouldGenerateLongValueCorrectly() {
|
||||
void shouldGenerateLongValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(Long.class));
|
||||
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value).isInstanceOf(Long.class);
|
||||
assertThat(value).isNotNull().isInstanceOf(Long.class);
|
||||
}
|
||||
|
||||
@Test // DATAKV-136
|
||||
public void shouldGenerateIntValueCorrectly() {
|
||||
void shouldGenerateIntValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(Integer.class));
|
||||
|
||||
assertThat(value).isNotNull();
|
||||
assertThat(value).isInstanceOf(Integer.class);
|
||||
assertThat(value).isNotNull().isInstanceOf(Integer.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.util.CloseableIterator;
|
||||
|
||||
/**
|
||||
@@ -34,14 +35,14 @@ import org.springframework.data.util.CloseableIterator;
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
|
||||
@Mock Iterator<Entry<K, V>> iteratorMock;
|
||||
@Mock Runnable closeActionMock;
|
||||
|
||||
@Test // DATAKV-99
|
||||
public void hasNextShouldDelegateToWrappedIterator() {
|
||||
void hasNextShouldDelegateToWrappedIterator() {
|
||||
|
||||
when(iteratorMock.hasNext()).thenReturn(true);
|
||||
|
||||
@@ -57,7 +58,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
|
||||
@Test // DATAKV-99
|
||||
@SuppressWarnings("unchecked")
|
||||
public void nextShouldDelegateToWrappedIterator() {
|
||||
void nextShouldDelegateToWrappedIterator() {
|
||||
|
||||
when(iteratorMock.next()).thenReturn((Entry<K, V>) mock(Map.Entry.class));
|
||||
|
||||
@@ -72,7 +73,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
}
|
||||
|
||||
@Test // DATAKV-99
|
||||
public void nextShouldThrowErrorWhenWrappedIteratorHasNoMoreElements() {
|
||||
void nextShouldThrowErrorWhenWrappedIteratorHasNoMoreElements() {
|
||||
|
||||
when(iteratorMock.next()).thenThrow(new NoSuchElementException());
|
||||
|
||||
@@ -86,7 +87,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
}
|
||||
|
||||
@Test // DATAKV-99
|
||||
public void closeShouldDoNothingByDefault() {
|
||||
void closeShouldDoNothingByDefault() {
|
||||
|
||||
new ForwardingCloseableIterator<>(iteratorMock).close();
|
||||
|
||||
@@ -94,7 +95,7 @@ public class ForwardingCloseableIteratorUnitTests<K, V> {
|
||||
}
|
||||
|
||||
@Test // DATAKV-99
|
||||
public void closeShouldInvokeConfiguredCloseAction() {
|
||||
void closeShouldInvokeConfiguredCloseAction() {
|
||||
|
||||
new ForwardingCloseableIterator<>(iteratorMock, closeActionMock).close();
|
||||
|
||||
|
||||
@@ -25,21 +25,21 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class IterableConverterUnitTests {
|
||||
class IterableConverterUnitTests {
|
||||
|
||||
@Test // DATAKV-101
|
||||
public void toListShouldReturnEmptyListWhenSourceEmpty() {
|
||||
void toListShouldReturnEmptyListWhenSourceEmpty() {
|
||||
assertThat(toList(Collections.emptySet())).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATAKV-101
|
||||
public void toListShouldReturnSameObjectWhenSourceIsAlreadyListType() {
|
||||
void toListShouldReturnSameObjectWhenSourceIsAlreadyListType() {
|
||||
|
||||
List<String> source = new ArrayList<>();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class IterableConverterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-101
|
||||
public void toListShouldReturnListWhenSourceIsNonListType() {
|
||||
void toListShouldReturnListWhenSourceIsNonListType() {
|
||||
|
||||
Set<String> source = new HashSet<>();
|
||||
source.add("tyrion");
|
||||
@@ -56,7 +56,7 @@ public class IterableConverterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-101
|
||||
public void toListShouldHoldValuesInOrderOfSource() {
|
||||
void toListShouldHoldValuesInOrderOfSource() {
|
||||
|
||||
Set<String> source = new LinkedHashSet<>();
|
||||
source.add("tyrion");
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
@@ -27,48 +27,48 @@ import org.springframework.dao.DataRetrievalFailureException;
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class KeyValuePersistenceExceptionTranslatorUnitTests {
|
||||
class KeyValuePersistenceExceptionTranslatorUnitTests {
|
||||
|
||||
KeyValuePersistenceExceptionTranslator translator = new KeyValuePersistenceExceptionTranslator();
|
||||
private KeyValuePersistenceExceptionTranslator translator = new KeyValuePersistenceExceptionTranslator();
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void translateExeptionShouldReturnDataAccessExceptionWhenGivenOne() {
|
||||
void translateExeptionShouldReturnDataAccessExceptionWhenGivenOne() {
|
||||
assertThat(translator.translateExceptionIfPossible(new DataRetrievalFailureException("booh")))
|
||||
.isInstanceOf(DataRetrievalFailureException.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525, DATAKV-192
|
||||
public void translateExeptionShouldReturnNullWhenGivenNull() {
|
||||
void translateExeptionShouldReturnNullWhenGivenNull() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> assertThat(translator.translateExceptionIfPossible(null)).isNull());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void translateExeptionShouldTranslateNoSuchElementExceptionToDataRetrievalFailureException() {
|
||||
void translateExeptionShouldTranslateNoSuchElementExceptionToDataRetrievalFailureException() {
|
||||
assertThat(translator.translateExceptionIfPossible(new NoSuchElementException("")))
|
||||
.isInstanceOf(DataRetrievalFailureException.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void translateExeptionShouldTranslateIndexOutOfBoundsExceptionToDataRetrievalFailureException() {
|
||||
void translateExeptionShouldTranslateIndexOutOfBoundsExceptionToDataRetrievalFailureException() {
|
||||
assertThat(translator.translateExceptionIfPossible(new IndexOutOfBoundsException("")))
|
||||
.isInstanceOf(DataRetrievalFailureException.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void translateExeptionShouldTranslateIllegalStateExceptionToDataRetrievalFailureException() {
|
||||
void translateExeptionShouldTranslateIllegalStateExceptionToDataRetrievalFailureException() {
|
||||
assertThat(translator.translateExceptionIfPossible(new IllegalStateException("")))
|
||||
.isInstanceOf(DataRetrievalFailureException.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void translateExeptionShouldTranslateAnyJavaExceptionToUncategorizedKeyValueException() {
|
||||
void translateExeptionShouldTranslateAnyJavaExceptionToUncategorizedKeyValueException() {
|
||||
assertThat(translator.translateExceptionIfPossible(new UnsupportedOperationException("")))
|
||||
.isInstanceOf(UncategorizedKeyValueException.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void translateExeptionShouldReturnNullForNonJavaExceptions() {
|
||||
void translateExeptionShouldReturnNullForNonJavaExceptions() {
|
||||
assertThat(translator.translateExceptionIfPossible(new NoSuchBeanDefinitionException(""))).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,10 @@ 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;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
@@ -45,45 +44,45 @@ import org.springframework.data.map.MapKeyValueAdapter;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class KeyValueTemplateTests {
|
||||
class KeyValueTemplateTests {
|
||||
|
||||
static final Foo FOO_ONE = new Foo("one");
|
||||
static final Foo FOO_TWO = new Foo("two");
|
||||
static final Foo FOO_THREE = new Foo("three");
|
||||
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<>("foo == 'two'");
|
||||
private static final Foo FOO_ONE = new Foo("one");
|
||||
private static final Foo FOO_TWO = new Foo("two");
|
||||
private static final Foo FOO_THREE = new Foo("three");
|
||||
private static final Bar BAR_ONE = new Bar("one");
|
||||
private static final ClassWithTypeAlias ALIASED = new ClassWithTypeAlias("super");
|
||||
private static final SubclassOfAliasedType SUBCLASS_OF_ALIASED = new SubclassOfAliasedType("sub");
|
||||
private static final KeyValueQuery<String> STRING_QUERY = new KeyValueQuery<>("foo == 'two'");
|
||||
|
||||
KeyValueTemplate operations;
|
||||
private KeyValueTemplate operations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws InstantiationException, IllegalAccessException {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.operations = new KeyValueTemplate(new MapKeyValueAdapter());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
void tearDown() throws Exception {
|
||||
this.operations.destroy();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldNotThorwErrorWhenExecutedHavingNonExistingIdAndNonNullValue() {
|
||||
void insertShouldNotThorwErrorWhenExecutedHavingNonExistingIdAndNonNullValue() {
|
||||
operations.insert("1", FOO_ONE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowExceptionForNullId() {
|
||||
void insertShouldThrowExceptionForNullId() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> operations.insert(null, FOO_ONE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowExceptionForNullObject() {
|
||||
void insertShouldThrowExceptionForNullObject() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> operations.insert("some-id", null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowExecptionWhenObjectOfSameTypeAlreadyExists() {
|
||||
void insertShouldThrowExecptionWhenObjectOfSameTypeAlreadyExists() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
|
||||
@@ -91,14 +90,14 @@ public class KeyValueTemplateTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldWorkCorrectlyWhenObjectsOfDifferentTypesWithSameIdAreInserted() {
|
||||
void insertShouldWorkCorrectlyWhenObjectsOfDifferentTypesWithSameIdAreInserted() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.insert("1", BAR_ONE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void createShouldReturnSameInstanceGenerateId() {
|
||||
void createShouldReturnSameInstanceGenerateId() {
|
||||
|
||||
ClassWithStringId source = new ClassWithStringId();
|
||||
ClassWithStringId target = operations.insert(source);
|
||||
@@ -107,39 +106,39 @@ public class KeyValueTemplateTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void createShouldRespectExistingId() {
|
||||
void createShouldRespectExistingId() {
|
||||
|
||||
ClassWithStringId source = new ClassWithStringId();
|
||||
source.id = "one";
|
||||
|
||||
operations.insert(source);
|
||||
|
||||
assertThat(operations.findById("one", ClassWithStringId.class)).isEqualTo(Optional.of(source));
|
||||
assertThat(operations.findById("one", ClassWithStringId.class)).contains(source);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdShouldReturnObjectWithMatchingIdAndType() {
|
||||
void findByIdShouldReturnObjectWithMatchingIdAndType() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.findById("1", Foo.class)).isEqualTo(Optional.of(FOO_ONE));
|
||||
assertThat(operations.findById("1", Foo.class)).contains(FOO_ONE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdSouldReturnOptionalEmptyIfNoMatchingIdFound() {
|
||||
void findByIdSouldReturnOptionalEmptyIfNoMatchingIdFound() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.findById("2", Foo.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdShouldReturnOptionalEmptyIfNoMatchingTypeFound() {
|
||||
void findByIdShouldReturnOptionalEmptyIfNoMatchingTypeFound() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.findById("1", Bar.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findShouldExecuteQueryCorrectly() {
|
||||
void findShouldExecuteQueryCorrectly() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.insert("2", FOO_TWO);
|
||||
@@ -150,7 +149,7 @@ public class KeyValueTemplateTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void readShouldReturnEmptyCollectionIfOffsetOutOfRange() {
|
||||
void readShouldReturnEmptyCollectionIfOffsetOutOfRange() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.insert("2", FOO_TWO);
|
||||
@@ -160,24 +159,24 @@ public class KeyValueTemplateTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void updateShouldReplaceExistingObject() {
|
||||
void updateShouldReplaceExistingObject() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.update("1", FOO_TWO);
|
||||
assertThat(operations.findById("1", Foo.class)).isEqualTo(Optional.of(FOO_TWO));
|
||||
assertThat(operations.findById("1", Foo.class)).contains(FOO_TWO);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void updateShouldRespectTypeInformation() {
|
||||
void updateShouldRespectTypeInformation() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.update("1", BAR_ONE);
|
||||
|
||||
assertThat(operations.findById("1", Foo.class)).isEqualTo(Optional.of(FOO_ONE));
|
||||
assertThat(operations.findById("1", Foo.class)).contains(FOO_ONE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteShouldRemoveObjectCorrectly() {
|
||||
void deleteShouldRemoveObjectCorrectly() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
operations.delete("1", Foo.class);
|
||||
@@ -185,31 +184,31 @@ public class KeyValueTemplateTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteReturnsNullWhenNotExisting() {
|
||||
void deleteReturnsNullWhenNotExisting() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.delete("2", Foo.class)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteReturnsRemovedObject() {
|
||||
void deleteReturnsRemovedObject() {
|
||||
|
||||
operations.insert("1", FOO_ONE);
|
||||
assertThat(operations.delete("1", Foo.class)).isEqualTo(FOO_ONE);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteThrowsExceptionWhenIdCannotBeExctracted() {
|
||||
void deleteThrowsExceptionWhenIdCannotBeExctracted() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> operations.delete(FOO_ONE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void countShouldReturnZeroWhenNoElementsPresent() {
|
||||
void countShouldReturnZeroWhenNoElementsPresent() {
|
||||
assertThat(operations.count(Foo.class)).isEqualTo(0L);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldRespectTypeAlias() {
|
||||
void insertShouldRespectTypeAlias() {
|
||||
|
||||
operations.insert("1", ALIASED);
|
||||
operations.insert("2", SUBCLASS_OF_ALIASED);
|
||||
@@ -248,7 +247,7 @@ public class KeyValueTemplateTests {
|
||||
@Id String id;
|
||||
String name;
|
||||
|
||||
public ClassWithTypeAlias(String name) {
|
||||
ClassWithTypeAlias(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -257,7 +256,7 @@ public class KeyValueTemplateTests {
|
||||
|
||||
private static final long serialVersionUID = -468809596668871479L;
|
||||
|
||||
public SubclassOfAliasedType(String name) {
|
||||
SubclassOfAliasedType(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,14 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
@@ -57,8 +59,9 @@ import org.springframework.data.keyvalue.core.query.KeyValueQuery;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class KeyValueTemplateUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
class KeyValueTemplateUnitTests {
|
||||
|
||||
private static final Foo FOO_ONE = new Foo("one");
|
||||
private static final Foo FOO_TWO = new Foo("two");
|
||||
@@ -72,24 +75,24 @@ public class KeyValueTemplateUnitTests {
|
||||
private KeyValueTemplate template;
|
||||
private @Mock ApplicationEventPublisher publisherMock;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.template = new KeyValueTemplate(adapterMock);
|
||||
this.template.setApplicationEventPublisher(publisherMock);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldThrowExceptionWhenCreatingNewTempateWithNullAdapter() {
|
||||
void shouldThrowExceptionWhenCreatingNewTempateWithNullAdapter() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new KeyValueTemplate(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldThrowExceptionWhenCreatingNewTempateWithNullMappingContext() {
|
||||
void shouldThrowExceptionWhenCreatingNewTempateWithNullMappingContext() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new KeyValueTemplate(adapterMock, null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldLookUpValuesBeforeInserting() {
|
||||
void insertShouldLookUpValuesBeforeInserting() {
|
||||
|
||||
template.insert("1", FOO_ONE);
|
||||
|
||||
@@ -97,7 +100,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldInsertUseClassNameAsDefaultKeyspace() {
|
||||
void insertShouldInsertUseClassNameAsDefaultKeyspace() {
|
||||
|
||||
template.insert("1", FOO_ONE);
|
||||
|
||||
@@ -105,7 +108,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-225
|
||||
public void insertShouldReturnInsertedObject() {
|
||||
void insertShouldReturnInsertedObject() {
|
||||
|
||||
ClassWithStringId object = new ClassWithStringId();
|
||||
|
||||
@@ -114,7 +117,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowExceptionWhenObectWithIdAlreadyExists() {
|
||||
void insertShouldThrowExceptionWhenObectWithIdAlreadyExists() {
|
||||
|
||||
when(adapterMock.contains(anyString(), anyString())).thenReturn(true);
|
||||
|
||||
@@ -122,17 +125,17 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowExceptionForNullId() {
|
||||
void insertShouldThrowExceptionForNullId() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.insert(null, FOO_ONE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowExceptionForNullObject() {
|
||||
void insertShouldThrowExceptionForNullObject() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.insert("some-id", null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldGenerateId() {
|
||||
void insertShouldGenerateId() {
|
||||
|
||||
ClassWithStringId target = template.insert(new ClassWithStringId());
|
||||
|
||||
@@ -140,12 +143,12 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowErrorWhenIdCannotBeResolved() {
|
||||
void insertShouldThrowErrorWhenIdCannotBeResolved() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.insert(FOO_ONE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldReturnSameInstanceGenerateId() {
|
||||
void insertShouldReturnSameInstanceGenerateId() {
|
||||
|
||||
ClassWithStringId source = new ClassWithStringId();
|
||||
ClassWithStringId target = template.insert(source);
|
||||
@@ -154,7 +157,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldRespectExistingId() {
|
||||
void insertShouldRespectExistingId() {
|
||||
|
||||
ClassWithStringId source = new ClassWithStringId();
|
||||
source.id = "one";
|
||||
@@ -165,12 +168,12 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdShouldReturnOptionalEmptyWhenNoElementsPresent() {
|
||||
void findByIdShouldReturnOptionalEmptyWhenNoElementsPresent() {
|
||||
assertThat(template.findById("1", Foo.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByIdShouldReturnObjectWithMatchingIdAndType() {
|
||||
void findByIdShouldReturnObjectWithMatchingIdAndType() {
|
||||
|
||||
template.findById("1", Foo.class);
|
||||
|
||||
@@ -178,12 +181,12 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525, DATAKV-187
|
||||
public void findByIdShouldThrowExceptionWhenGivenNullId() {
|
||||
void findByIdShouldThrowExceptionWhenGivenNullId() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.findById(null, Foo.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllOfShouldReturnEntireCollection() {
|
||||
void findAllOfShouldReturnEntireCollection() {
|
||||
|
||||
template.findAll(Foo.class);
|
||||
|
||||
@@ -191,12 +194,12 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllOfShouldThrowExceptionWhenGivenNullType() {
|
||||
void findAllOfShouldThrowExceptionWhenGivenNullType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.findAll(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findShouldCallFindOnAdapterToResolveMatching() {
|
||||
void findShouldCallFindOnAdapterToResolveMatching() {
|
||||
|
||||
template.find(STRING_QUERY, Foo.class);
|
||||
|
||||
@@ -205,7 +208,7 @@ public class KeyValueTemplateUnitTests {
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void findInRangeShouldRespectOffset() {
|
||||
void findInRangeShouldRespectOffset() {
|
||||
|
||||
ArgumentCaptor<KeyValueQuery> captor = ArgumentCaptor.forClass(KeyValueQuery.class);
|
||||
|
||||
@@ -218,7 +221,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void updateShouldReplaceExistingObject() {
|
||||
void updateShouldReplaceExistingObject() {
|
||||
|
||||
template.update("1", FOO_TWO);
|
||||
|
||||
@@ -226,7 +229,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-225
|
||||
public void updateShouldReturnUpdatedObject() {
|
||||
void updateShouldReturnUpdatedObject() {
|
||||
|
||||
ClassWithStringId object = new ClassWithStringId();
|
||||
object.id = "foo";
|
||||
@@ -236,17 +239,17 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void updateShouldThrowExceptionWhenGivenNullId() {
|
||||
void updateShouldThrowExceptionWhenGivenNullId() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.update(null, FOO_ONE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void updateShouldThrowExceptionWhenGivenNullObject() {
|
||||
void updateShouldThrowExceptionWhenGivenNullObject() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.update("1", null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void updateShouldUseExtractedIdInformation() {
|
||||
void updateShouldUseExtractedIdInformation() {
|
||||
|
||||
ClassWithStringId source = new ClassWithStringId();
|
||||
source.id = "some-id";
|
||||
@@ -257,12 +260,12 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void updateShouldThrowErrorWhenIdInformationCannotBeExtracted() {
|
||||
void updateShouldThrowErrorWhenIdInformationCannotBeExtracted() {
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() -> template.update(FOO_ONE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteShouldRemoveObjectCorrectly() {
|
||||
void deleteShouldRemoveObjectCorrectly() {
|
||||
|
||||
template.delete("1", Foo.class);
|
||||
|
||||
@@ -270,7 +273,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteRemovesObjectUsingExtractedId() {
|
||||
void deleteRemovesObjectUsingExtractedId() {
|
||||
|
||||
ClassWithStringId source = new ClassWithStringId();
|
||||
source.id = "some-id";
|
||||
@@ -281,17 +284,17 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteThrowsExceptionWhenIdCannotBeExctracted() {
|
||||
void deleteThrowsExceptionWhenIdCannotBeExctracted() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.delete(FOO_ONE));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void countShouldReturnZeroWhenNoElementsPresent() {
|
||||
void countShouldReturnZeroWhenNoElementsPresent() {
|
||||
template.count(Foo.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void countShouldReturnCollectionSize() {
|
||||
void countShouldReturnCollectionSize() {
|
||||
|
||||
when(adapterMock.count(Foo.class.getName())).thenReturn(2L);
|
||||
|
||||
@@ -299,12 +302,12 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void countShouldThrowErrorOnNullType() {
|
||||
void countShouldThrowErrorOnNullType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.count(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldRespectTypeAlias() {
|
||||
void insertShouldRespectTypeAlias() {
|
||||
|
||||
template.insert("1", ALIASED_USING_ALIAS_FOR);
|
||||
|
||||
@@ -312,7 +315,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldRespectTypeAliasOnSubClass() {
|
||||
void insertShouldRespectTypeAliasOnSubClass() {
|
||||
|
||||
template.insert("1", SUBCLASS_OF_ALIASED_USING_ALIAS_FOR);
|
||||
|
||||
@@ -321,7 +324,7 @@ public class KeyValueTemplateUnitTests {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test // DATACMNS-525
|
||||
public void findAllOfShouldRespectTypeAliasAndFilterNonMatchingTypes() {
|
||||
void findAllOfShouldRespectTypeAliasAndFilterNonMatchingTypes() {
|
||||
|
||||
Collection foo = Arrays.asList(ALIASED_USING_ALIAS_FOR, SUBCLASS_OF_ALIASED_USING_ALIAS_FOR);
|
||||
when(adapterMock.getAllOf("aliased")).thenReturn(foo);
|
||||
@@ -331,19 +334,19 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertSouldRespectTypeAliasAndFilterNonMatching() {
|
||||
void insertSouldRespectTypeAliasAndFilterNonMatching() {
|
||||
|
||||
template.insert("1", ALIASED_USING_ALIAS_FOR);
|
||||
assertThat(template.findById("1", SUBCLASS_OF_ALIASED_USING_ALIAS_FOR.getClass())).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void setttingNullPersistenceExceptionTranslatorShouldThrowException() {
|
||||
void setttingNullPersistenceExceptionTranslatorShouldThrowException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> template.setExceptionTranslator(null));
|
||||
}
|
||||
|
||||
@Test // DATAKV-91
|
||||
public void shouldNotPublishEventWhenNoApplicationContextSet() {
|
||||
void shouldNotPublishEventWhenNoApplicationContextSet() {
|
||||
|
||||
template.setApplicationEventPublisher(null);
|
||||
|
||||
@@ -353,7 +356,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-104
|
||||
public void shouldNotPublishEventsWhenEventsToPublishIsSetToNull() {
|
||||
void shouldNotPublishEventsWhenEventsToPublishIsSetToNull() {
|
||||
|
||||
template.setEventTypesToPublish(null);
|
||||
|
||||
@@ -363,8 +366,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-104
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void shouldNotPublishEventsWhenEventsToPublishIsSetToEmptyList() {
|
||||
|
||||
void shouldNotPublishEventsWhenEventsToPublishIsSetToEmptyList() {
|
||||
|
||||
template.setEventTypesToPublish(Collections.emptySet());
|
||||
|
||||
@@ -374,7 +377,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-104
|
||||
public void shouldPublishEventsByDefault() {
|
||||
void shouldPublishEventsByDefault() {
|
||||
|
||||
template.insert("1", FOO_ONE);
|
||||
|
||||
@@ -382,8 +385,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104
|
||||
@SuppressWarnings({ "unchecked", })
|
||||
public void shouldNotPublishEventWhenNotExplicitlySetForPublication() {
|
||||
|
||||
void shouldNotPublishEventWhenNotExplicitlySetForPublication() {
|
||||
|
||||
setEventsToPublish(BeforeDeleteEvent.class);
|
||||
|
||||
@@ -393,8 +396,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldPublishBeforeInsertEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishBeforeInsertEventCorrectly() {
|
||||
|
||||
setEventsToPublish(BeforeInsertEvent.class);
|
||||
|
||||
@@ -411,8 +414,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldPublishAfterInsertEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishAfterInsertEventCorrectly() {
|
||||
|
||||
setEventsToPublish(AfterInsertEvent.class);
|
||||
|
||||
@@ -429,8 +432,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldPublishBeforeUpdateEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishBeforeUpdateEventCorrectly() {
|
||||
|
||||
setEventsToPublish(BeforeUpdateEvent.class);
|
||||
|
||||
@@ -447,8 +450,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldPublishAfterUpdateEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishAfterUpdateEventCorrectly() {
|
||||
|
||||
setEventsToPublish(AfterUpdateEvent.class);
|
||||
|
||||
@@ -465,8 +468,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void shouldPublishBeforeDeleteEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishBeforeDeleteEventCorrectly() {
|
||||
|
||||
setEventsToPublish(BeforeDeleteEvent.class);
|
||||
|
||||
@@ -482,8 +485,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void shouldPublishAfterDeleteEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishAfterDeleteEventCorrectly() {
|
||||
|
||||
setEventsToPublish(AfterDeleteEvent.class);
|
||||
when(adapterMock.delete(eq("1"), eq(FOO_ONE.getClass().getName()), eq(Foo.class))).thenReturn(FOO_ONE);
|
||||
@@ -501,8 +504,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void shouldPublishBeforeGetEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishBeforeGetEventCorrectly() {
|
||||
|
||||
setEventsToPublish(BeforeGetEvent.class);
|
||||
|
||||
@@ -520,8 +523,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void shouldPublishAfterGetEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishAfterGetEventCorrectly() {
|
||||
|
||||
setEventsToPublish(AfterGetEvent.class);
|
||||
|
||||
@@ -540,8 +543,8 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-91, DATAKV-104, DATAKV-187
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void shouldPublishDropKeyspaceEventCorrectly() {
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
void shouldPublishDropKeyspaceEventCorrectly() {
|
||||
|
||||
setEventsToPublish(AfterDropKeySpaceEvent.class);
|
||||
|
||||
@@ -556,7 +559,7 @@ public class KeyValueTemplateUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-129
|
||||
public void insertShouldRespectTypeAliasUsingAliasFor() {
|
||||
void insertShouldRespectTypeAliasUsingAliasFor() {
|
||||
|
||||
template.insert("1", ALIASED_USING_ALIAS_FOR);
|
||||
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.core;
|
||||
|
||||
import static java.lang.Integer.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
||||
@@ -30,7 +29,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class SpelPropertyComperatorUnitTests {
|
||||
class SpelPropertyComperatorUnitTests {
|
||||
|
||||
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
@@ -40,71 +39,71 @@ public class SpelPropertyComperatorUnitTests {
|
||||
private static final WrapperType WRAPPER_TWO = new WrapperType("w-two", TWO);
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareStringAscCorrectly() {
|
||||
void shouldCompareStringAscCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("stringProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, TWO)).isEqualTo(ONE.getStringProperty().compareTo(TWO.getStringProperty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareStringDescCorrectly() {
|
||||
void shouldCompareStringDescCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("stringProperty", PARSER).desc();
|
||||
assertThat(comparator.compare(ONE, TWO)).isEqualTo(TWO.getStringProperty().compareTo(ONE.getStringProperty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareIntegerAscCorrectly() {
|
||||
void shouldCompareIntegerAscCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("integerProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, TWO)).isEqualTo(ONE.getIntegerProperty().compareTo(TWO.getIntegerProperty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareIntegerDescCorrectly() {
|
||||
void shouldCompareIntegerDescCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("integerProperty", PARSER).desc();
|
||||
assertThat(comparator.compare(ONE, TWO)).isEqualTo(TWO.getIntegerProperty().compareTo(ONE.getIntegerProperty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldComparePrimitiveIntegerAscCorrectly() {
|
||||
void shouldComparePrimitiveIntegerAscCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("primitiveProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, TWO))
|
||||
.isEqualTo(valueOf(ONE.getPrimitiveProperty()).compareTo(valueOf(TWO.getPrimitiveProperty())));
|
||||
.isEqualTo(Integer.compare(ONE.getPrimitiveProperty(), TWO.getPrimitiveProperty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldNotFailOnNullValues() {
|
||||
void shouldNotFailOnNullValues() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<>("stringProperty", PARSER);
|
||||
assertThat(comparator.compare(ONE, new SomeType(null, null, 2))).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldComparePrimitiveIntegerDescCorrectly() {
|
||||
void shouldComparePrimitiveIntegerDescCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("primitiveProperty", PARSER).desc();
|
||||
assertThat(comparator.compare(ONE, TWO))
|
||||
.isEqualTo(valueOf(TWO.getPrimitiveProperty()).compareTo(valueOf(ONE.getPrimitiveProperty())));
|
||||
.isEqualTo(Integer.compare(TWO.getPrimitiveProperty(), ONE.getPrimitiveProperty()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldSortNullsFirstCorrectly() {
|
||||
void shouldSortNullsFirstCorrectly() {
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("stringProperty", PARSER).nullsFirst();
|
||||
assertThat(comparator.compare(ONE, new SomeType(null, null, 2))).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldSortNullsLastCorrectly() {
|
||||
void shouldSortNullsLastCorrectly() {
|
||||
|
||||
Comparator<SomeType> comparator = new SpelPropertyComparator<SomeType>("stringProperty", PARSER).nullsLast();
|
||||
assertThat(comparator.compare(ONE, new SomeType(null, null, 2))).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareNestedTypesCorrectly() {
|
||||
void shouldCompareNestedTypesCorrectly() {
|
||||
|
||||
Comparator<WrapperType> comparator = new SpelPropertyComparator<>("nestedType.stringProperty", PARSER);
|
||||
assertThat(comparator.compare(WRAPPER_ONE, WRAPPER_TWO)).isEqualTo(
|
||||
@@ -112,18 +111,18 @@ public class SpelPropertyComperatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldCompareNestedTypesCorrectlyWhenOneOfThemHasNullValue() {
|
||||
void shouldCompareNestedTypesCorrectlyWhenOneOfThemHasNullValue() {
|
||||
|
||||
SpelPropertyComparator<WrapperType> comparator = new SpelPropertyComparator<>("nestedType.stringProperty", PARSER);
|
||||
assertThat(comparator.compare(WRAPPER_ONE, new WrapperType("two", null))).isGreaterThanOrEqualTo(1);
|
||||
}
|
||||
|
||||
static class WrapperType {
|
||||
public static class WrapperType {
|
||||
|
||||
private String stringPropertyWrapper;
|
||||
private SomeType nestedType;
|
||||
|
||||
public WrapperType(String stringPropertyWrapper, SomeType nestedType) {
|
||||
WrapperType(String stringPropertyWrapper, SomeType nestedType) {
|
||||
this.stringPropertyWrapper = stringPropertyWrapper;
|
||||
this.nestedType = nestedType;
|
||||
}
|
||||
@@ -146,13 +145,14 @@ public class SpelPropertyComperatorUnitTests {
|
||||
|
||||
}
|
||||
|
||||
static class SomeType {
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public static class SomeType {
|
||||
|
||||
public SomeType() {
|
||||
|
||||
}
|
||||
|
||||
public SomeType(String stringProperty, Integer integerProperty, int primitiveProperty) {
|
||||
SomeType(String stringProperty, Integer integerProperty, int primitiveProperty) {
|
||||
this.stringProperty = stringProperty;
|
||||
this.integerProperty = integerProperty;
|
||||
this.primitiveProperty = primitiveProperty;
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.keyvalue.repository.query.SpelQueryCreator;
|
||||
@@ -47,20 +47,20 @@ import org.springframework.expression.spel.support.SimpleEvaluationContext;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class SpelQueryEngineUnitTests {
|
||||
|
||||
static final Person BOB_WITH_FIRSTNAME = new Person("bob", 30);
|
||||
static final Person MIKE_WITHOUT_FIRSTNAME = new Person(null, 25);
|
||||
private static final Person BOB_WITH_FIRSTNAME = new Person("bob", 30);
|
||||
private static final Person MIKE_WITHOUT_FIRSTNAME = new Person(null, 25);
|
||||
|
||||
@Mock KeyValueAdapter adapter;
|
||||
|
||||
SpelQueryEngine engine;
|
||||
private SpelQueryEngine engine;
|
||||
|
||||
Iterable<Person> people = Arrays.asList(BOB_WITH_FIRSTNAME, MIKE_WITHOUT_FIRSTNAME);
|
||||
private Iterable<Person> people = Arrays.asList(BOB_WITH_FIRSTNAME, MIKE_WITHOUT_FIRSTNAME);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
engine = new SpelQueryEngine();
|
||||
engine.registerAdapter(adapter);
|
||||
@@ -68,7 +68,7 @@ public class SpelQueryEngineUnitTests {
|
||||
|
||||
@Test // DATAKV-114
|
||||
@SuppressWarnings("unchecked")
|
||||
public void queriesEntitiesWithNullProperty() throws Exception {
|
||||
void queriesEntitiesWithNullProperty() throws Exception {
|
||||
|
||||
doReturn(people).when(adapter).getAllOf(anyString());
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SpelQueryEngineUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-114
|
||||
public void countsEntitiesWithNullProperty() throws Exception {
|
||||
void countsEntitiesWithNullProperty() throws Exception {
|
||||
|
||||
doReturn(people).when(adapter).getAllOf(anyString());
|
||||
|
||||
@@ -110,13 +110,13 @@ public class SpelQueryEngineUnitTests {
|
||||
Person findByFirstname(String firstname);
|
||||
}
|
||||
|
||||
static class Person {
|
||||
public static class Person {
|
||||
|
||||
@Id String id;
|
||||
String firstname;
|
||||
int age;
|
||||
|
||||
public Person(String firstname, int age) {
|
||||
Person(String firstname, int age) {
|
||||
|
||||
this.firstname = firstname;
|
||||
this.age = age;
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.data.annotation.Persistent;
|
||||
@@ -38,57 +38,57 @@ import org.springframework.data.keyvalue.annotation.KeySpace;
|
||||
* @author Christoph Strobl
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class AnnotationBasedKeySpaceResolverUnitTests {
|
||||
class AnnotationBasedKeySpaceResolverUnitTests {
|
||||
|
||||
private AnnotationBasedKeySpaceResolver resolver;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
resolver = AnnotationBasedKeySpaceResolver.INSTANCE;
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldResolveKeySpaceDefaultValueCorrectly() {
|
||||
void shouldResolveKeySpaceDefaultValueCorrectly() {
|
||||
assertThat(resolver.resolveKeySpace(EntityWithDefaultKeySpace.class)).isEqualTo("daenerys");
|
||||
}
|
||||
|
||||
@Test // DATAKV-105
|
||||
public void shouldReturnNullWhenNoKeySpaceFoundOnComposedPersistentAnnotation() {
|
||||
void shouldReturnNullWhenNoKeySpaceFoundOnComposedPersistentAnnotation() {
|
||||
assertThat(resolver.resolveKeySpace(TypeWithInhteritedPersistentAnnotationNotHavingKeySpace.class)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATAKV-105
|
||||
public void shouldReturnNullWhenPersistentIsFoundOnNonComposedAnnotation() {
|
||||
void shouldReturnNullWhenPersistentIsFoundOnNonComposedAnnotation() {
|
||||
assertThat(resolver.resolveKeySpace(TypeWithPersistentAnnotationNotHavingKeySpace.class)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATAKV-105
|
||||
public void shouldReturnNullWhenPersistentIsNotFound() {
|
||||
void shouldReturnNullWhenPersistentIsNotFound() {
|
||||
assertThat(resolver.resolveKeySpace(TypeWithoutKeySpace.class)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldResolveInheritedKeySpaceCorrectly() {
|
||||
void shouldResolveInheritedKeySpaceCorrectly() {
|
||||
assertThat(resolver.resolveKeySpace(EntityWithInheritedKeySpace.class)).isEqualTo("viserys");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldResolveDirectKeySpaceAnnotationCorrectly() {
|
||||
void shouldResolveDirectKeySpaceAnnotationCorrectly() {
|
||||
assertThat(resolver.resolveKeySpace(TypeWithDirectKeySpaceAnnotation.class)).isEqualTo("rhaegar");
|
||||
}
|
||||
|
||||
@Test // DATAKV-129
|
||||
public void shouldResolveKeySpaceUsingAliasForCorrectly() {
|
||||
void shouldResolveKeySpaceUsingAliasForCorrectly() {
|
||||
assertThat(resolver.resolveKeySpace(EntityWithSetKeySpaceUsingAliasFor.class)).isEqualTo("viserys");
|
||||
}
|
||||
|
||||
@Test // DATAKV-129
|
||||
public void shouldResolveKeySpaceUsingAliasForCorrectlyOnSubClass() {
|
||||
void shouldResolveKeySpaceUsingAliasForCorrectlyOnSubClass() {
|
||||
assertThat(resolver.resolveKeySpace(EntityWithInheritedKeySpaceUsingAliasFor.class)).isEqualTo("viserys");
|
||||
}
|
||||
|
||||
@PersistentAnnotationWithExplicitKeySpaceUsingAliasFor
|
||||
static class EntityWithDefaultKeySpace {
|
||||
private static class EntityWithDefaultKeySpace {
|
||||
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ public class AnnotationBasedKeySpaceResolverUnitTests {
|
||||
|
||||
}
|
||||
|
||||
static class EntityWithInheritedKeySpace extends EntityWithSetKeySpaceUsingAliasFor {
|
||||
private static class EntityWithInheritedKeySpace extends EntityWithSetKeySpaceUsingAliasFor {
|
||||
|
||||
}
|
||||
|
||||
static class EntityWithInheritedKeySpaceUsingAliasFor extends EntityWithSetKeySpaceUsingAliasFor {
|
||||
private static class EntityWithInheritedKeySpaceUsingAliasFor extends EntityWithSetKeySpaceUsingAliasFor {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.keyvalue.annotation.KeySpace;
|
||||
import org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
@@ -33,19 +33,19 @@ import org.springframework.data.spel.spi.EvaluationContextExtension;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class BasicKeyValuePersistentEntityUnitTests {
|
||||
class BasicKeyValuePersistentEntityUnitTests {
|
||||
|
||||
MappingContext<? extends KeyValuePersistentEntity<?, ?>, ? extends KeyValuePersistentProperty<?>> mappingContext = new KeyValueMappingContext<>();
|
||||
private MappingContext<? extends KeyValuePersistentEntity<?, ?>, ? extends KeyValuePersistentProperty<?>> mappingContext = new KeyValueMappingContext<>();
|
||||
|
||||
@Test // DATAKV-268
|
||||
public void shouldDeriveKeyspaceFromClassName() {
|
||||
void shouldDeriveKeyspaceFromClassName() {
|
||||
|
||||
assertThat(mappingContext.getPersistentEntity(KeyspaceEntity.class).getKeySpace())
|
||||
.isEqualTo(KeyspaceEntity.class.getName());
|
||||
}
|
||||
|
||||
@Test // DATAKV-268
|
||||
public void shouldEvaluateKeyspaceExpression() {
|
||||
void shouldEvaluateKeyspaceExpression() {
|
||||
|
||||
KeyValuePersistentEntity<?, ?> persistentEntity = mappingContext.getPersistentEntity(ExpressionEntity.class);
|
||||
persistentEntity.setEvaluationContextProvider(
|
||||
@@ -55,7 +55,7 @@ public class BasicKeyValuePersistentEntityUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-268
|
||||
public void shouldEvaluateEntityWithoutKeyspace() {
|
||||
void shouldEvaluateEntityWithoutKeyspace() {
|
||||
|
||||
KeyValuePersistentEntity<?, ?> persistentEntity = mappingContext.getPersistentEntity(NoKeyspaceEntity.class);
|
||||
persistentEntity.setEvaluationContextProvider(
|
||||
@@ -65,12 +65,12 @@ public class BasicKeyValuePersistentEntityUnitTests {
|
||||
}
|
||||
|
||||
@KeySpace("#{myProperty}")
|
||||
static class ExpressionEntity {}
|
||||
private static class ExpressionEntity {}
|
||||
|
||||
@KeySpace
|
||||
static class KeyspaceEntity {}
|
||||
private static class KeyspaceEntity {}
|
||||
|
||||
static class NoKeyspaceEntity {}
|
||||
private static class NoKeyspaceEntity {}
|
||||
|
||||
static class SampleExtension implements EvaluationContextExtension {
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import lombok.NoArgsConstructor;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Persistent;
|
||||
@@ -48,15 +48,15 @@ import org.springframework.data.repository.core.support.PersistentEntityInformat
|
||||
* @author Eugene Nikiforov
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SimpleKeyValueRepositoryUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SimpleKeyValueRepositoryUnitTests {
|
||||
|
||||
private SimpleKeyValueRepository<Foo, String> repo;
|
||||
private @Mock KeyValueOperations opsMock;
|
||||
KeyValueMappingContext<?, ?> context;
|
||||
private KeyValueMappingContext<?, ?> context;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.context = new KeyValueMappingContext<>();
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void saveNewWithNumericId() {
|
||||
void saveNewWithNumericId() {
|
||||
|
||||
EntityInformation<WithNumericId, ?> ei = getEntityInformationFor(WithNumericId.class);
|
||||
SimpleKeyValueRepository<WithNumericId, ?> temp = new SimpleKeyValueRepository<>(ei, opsMock);
|
||||
@@ -77,7 +77,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void testDoubleSave() {
|
||||
void testDoubleSave() {
|
||||
|
||||
Foo foo = new Foo("one");
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void multipleSave() {
|
||||
void multipleSave() {
|
||||
|
||||
Foo one = new Foo("one");
|
||||
Foo two = new Foo("two");
|
||||
@@ -101,7 +101,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteEntity() {
|
||||
void deleteEntity() {
|
||||
|
||||
Foo one = new Foo("one");
|
||||
one.id = "1";
|
||||
@@ -112,7 +112,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteById() {
|
||||
void deleteById() {
|
||||
|
||||
repo.deleteById("one");
|
||||
|
||||
@@ -120,7 +120,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-330
|
||||
public void deleteAllById() {
|
||||
void deleteAllById() {
|
||||
|
||||
repo.deleteAllById(Arrays.asList("one", "two"));
|
||||
|
||||
@@ -129,7 +129,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteAll() {
|
||||
void deleteAll() {
|
||||
|
||||
repo.deleteAll();
|
||||
|
||||
@@ -138,7 +138,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
|
||||
@Test // DATACMNS-525
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findAllIds() {
|
||||
void findAllIds() {
|
||||
|
||||
when(opsMock.findById(any(), any(Class.class))).thenReturn(Optional.empty());
|
||||
repo.findAllById(Arrays.asList("one", "two", "three"));
|
||||
@@ -148,7 +148,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
|
||||
@Test // DATAKV-186
|
||||
@SuppressWarnings("unchecked")
|
||||
public void existsByIdReturnsFalseForEmptyOptional() {
|
||||
void existsByIdReturnsFalseForEmptyOptional() {
|
||||
|
||||
when(opsMock.findById(any(), any(Class.class))).thenReturn(Optional.empty());
|
||||
assertThat(repo.existsById("one")).isFalse();
|
||||
@@ -156,14 +156,14 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
|
||||
@Test // DATAKV-186
|
||||
@SuppressWarnings("unchecked")
|
||||
public void existsByIdReturnsTrueWhenOptionalValuePresent() {
|
||||
void existsByIdReturnsTrueWhenOptionalValuePresent() {
|
||||
|
||||
when(opsMock.findById(any(), any(Class.class))).thenReturn(Optional.of(new Foo()));
|
||||
assertThat(repo.existsById("one")).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllWithPageableShouldDelegateToOperationsCorrectlyWhenPageableDoesNotContainSort() {
|
||||
void findAllWithPageableShouldDelegateToOperationsCorrectlyWhenPageableDoesNotContainSort() {
|
||||
|
||||
repo.findAll(PageRequest.of(10, 15));
|
||||
|
||||
@@ -171,7 +171,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllWithPageableShouldDelegateToOperationsCorrectlyWhenPageableContainsSort() {
|
||||
void findAllWithPageableShouldDelegateToOperationsCorrectlyWhenPageableContainsSort() {
|
||||
|
||||
Sort sort = Sort.by("for", "bar");
|
||||
repo.findAll(PageRequest.of(10, 15, sort));
|
||||
@@ -180,7 +180,7 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllShouldFallbackToFindAllOfWhenGivenNullPageable() {
|
||||
void findAllShouldFallbackToFindAllOfWhenGivenNullPageable() {
|
||||
|
||||
repo.findAll(Pageable.unpaged());
|
||||
|
||||
@@ -205,13 +205,13 @@ public class SimpleKeyValueRepositoryUnitTests {
|
||||
private String name;
|
||||
private Bar bar;
|
||||
|
||||
public Foo(String name) {
|
||||
Foo(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Bar {
|
||||
private static class Bar {
|
||||
|
||||
private String bar;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ import static org.mockito.Mockito.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.keyvalue.Person;
|
||||
import org.springframework.data.keyvalue.core.KeyValueOperations;
|
||||
@@ -42,16 +42,16 @@ import org.springframework.data.util.ClassTypeInformation;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CachingKeyValuePartTreeQueryUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class CachingKeyValuePartTreeQueryUnitTests {
|
||||
|
||||
@Mock KeyValueOperations kvOpsMock;
|
||||
@Mock RepositoryMetadata metadataMock;
|
||||
@Mock ProjectionFactory projectionFactoryMock;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void setUp() throws Exception {
|
||||
void setUp() throws Exception {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
|
||||
@@ -59,7 +59,7 @@ public class CachingKeyValuePartTreeQueryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-137
|
||||
public void cachedSpelExpressionShouldBeReusedWithNewContext() throws NoSuchMethodException, SecurityException {
|
||||
void cachedSpelExpressionShouldBeReusedWithNewContext() throws NoSuchMethodException, SecurityException {
|
||||
|
||||
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findByFirstname", String.class), metadataMock,
|
||||
projectionFactoryMock);
|
||||
|
||||
@@ -22,10 +22,10 @@ import static org.mockito.Mockito.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -44,8 +44,8 @@ import org.springframework.data.util.TypeInformation;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class KeyValuePartTreeQueryUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
@Mock KeyValueOperations kvOpsMock;
|
||||
@Mock RepositoryMetadata metadataMock;
|
||||
@@ -53,7 +53,7 @@ public class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
@Test // DATAKV-115
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void spelExpressionAndContextShouldNotBeReused() throws NoSuchMethodException, SecurityException {
|
||||
void spelExpressionAndContextShouldNotBeReused() throws NoSuchMethodException, SecurityException {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
@@ -76,7 +76,7 @@ public class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
@Test // DATAKV-142
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldApplyPageableParameterToCollectionQuery() throws SecurityException, NoSuchMethodException {
|
||||
void shouldApplyPageableParameterToCollectionQuery() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
@@ -97,7 +97,7 @@ public class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
@Test // DATAKV-142
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldApplyDerivedMaxResultsToQuery() throws SecurityException, NoSuchMethodException {
|
||||
void shouldApplyDerivedMaxResultsToQuery() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
@@ -116,7 +116,7 @@ public class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
@Test // DATAKV-142
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void shouldApplyDerivedMaxResultsToQueryWithParameters() throws SecurityException, NoSuchMethodException {
|
||||
void shouldApplyDerivedMaxResultsToQueryWithParameters() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
|
||||
@@ -27,10 +27,10 @@ import java.util.Date;
|
||||
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -49,226 +49,226 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class SpelQueryCreatorUnitTests {
|
||||
|
||||
static final DateTimeFormatter FORMATTER = ISODateTimeFormat.dateTimeNoMillis().withZoneUTC();
|
||||
private static final DateTimeFormatter FORMATTER = ISODateTimeFormat.dateTimeNoMillis().withZoneUTC();
|
||||
|
||||
static final Person RICKON = new Person("rickon", 4);
|
||||
static final Person BRAN = new Person("bran", 9)//
|
||||
private static final Person RICKON = new Person("rickon", 4);
|
||||
private static final Person BRAN = new Person("bran", 9)//
|
||||
.skinChanger(true)//
|
||||
.bornAt(FORMATTER.parseDateTime("2013-01-31T06:00:00Z").toDate());
|
||||
static final Person ARYA = new Person("arya", 13);
|
||||
static final Person ROBB = new Person("robb", 16)//
|
||||
private static final Person ARYA = new Person("arya", 13);
|
||||
private static final Person ROBB = new Person("robb", 16)//
|
||||
.named("stark")//
|
||||
.bornAt(FORMATTER.parseDateTime("2010-09-20T06:00:00Z").toDate());
|
||||
static final Person JON = new Person("jon", 17).named("snow");
|
||||
private static final Person JON = new Person("jon", 17).named("snow");
|
||||
|
||||
@Mock RepositoryMetadata metadataMock;
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void equalsReturnsTrueWhenMatching() {
|
||||
void equalsReturnsTrueWhenMatching() {
|
||||
assertThat(evaluate("findByFirstname", BRAN.firstname).against(BRAN)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void equalsReturnsFalseWhenNotMatching() {
|
||||
void equalsReturnsFalseWhenNotMatching() {
|
||||
assertThat(evaluate("findByFirstname", BRAN.firstname).against(RICKON)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isTrueAssertedProperlyWhenTrue() {
|
||||
void isTrueAssertedProperlyWhenTrue() {
|
||||
assertThat(evaluate("findBySkinChangerIsTrue").against(BRAN)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isTrueAssertedProperlyWhenFalse() {
|
||||
void isTrueAssertedProperlyWhenFalse() {
|
||||
assertThat(evaluate("findBySkinChangerIsTrue").against(RICKON)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isFalseAssertedProperlyWhenTrue() {
|
||||
void isFalseAssertedProperlyWhenTrue() {
|
||||
assertThat(evaluate("findBySkinChangerIsFalse").against(BRAN)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isFalseAssertedProperlyWhenFalse() {
|
||||
void isFalseAssertedProperlyWhenFalse() {
|
||||
assertThat(evaluate("findBySkinChangerIsFalse").against(RICKON)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isNullAssertedProperlyWhenAttributeIsNull() {
|
||||
void isNullAssertedProperlyWhenAttributeIsNull() {
|
||||
assertThat(evaluate("findByLastnameIsNull").against(BRAN)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isNullAssertedProperlyWhenAttributeIsNotNull() {
|
||||
void isNullAssertedProperlyWhenAttributeIsNotNull() {
|
||||
assertThat(evaluate("findByLastnameIsNull").against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isNotNullFalseTrueWhenAttributeIsNull() {
|
||||
void isNotNullFalseTrueWhenAttributeIsNull() {
|
||||
assertThat(evaluate("findByLastnameIsNotNull").against(BRAN)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void isNotNullReturnsTrueAttributeIsNotNull() {
|
||||
void isNotNullReturnsTrueAttributeIsNotNull() {
|
||||
assertThat(evaluate("findByLastnameIsNotNull").against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void startsWithReturnsTrueWhenMatching() {
|
||||
void startsWithReturnsTrueWhenMatching() {
|
||||
assertThat(evaluate("findByFirstnameStartingWith", "r").against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void startsWithReturnsFalseWhenNotMatching() {
|
||||
void startsWithReturnsFalseWhenNotMatching() {
|
||||
assertThat(evaluate("findByFirstnameStartingWith", "r").against(BRAN)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void likeReturnsTrueWhenMatching() {
|
||||
void likeReturnsTrueWhenMatching() {
|
||||
assertThat(evaluate("findByFirstnameLike", "ob").against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void likeReturnsFalseWhenNotMatching() {
|
||||
void likeReturnsFalseWhenNotMatching() {
|
||||
assertThat(evaluate("findByFirstnameLike", "ra").against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void endsWithReturnsTrueWhenMatching() {
|
||||
void endsWithReturnsTrueWhenMatching() {
|
||||
assertThat(evaluate("findByFirstnameEndingWith", "bb").against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void endsWithReturnsFalseWhenNotMatching() {
|
||||
void endsWithReturnsFalseWhenNotMatching() {
|
||||
assertThat(evaluate("findByFirstnameEndingWith", "an").against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void startsWithIgnoreCaseReturnsTrueWhenMatching() {
|
||||
void startsWithIgnoreCaseReturnsTrueWhenMatching() {
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
.isThrownBy(() -> evaluate("findByFirstnameIgnoreCase", "R").against(ROBB));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void greaterThanReturnsTrueForHigherValues() {
|
||||
void greaterThanReturnsTrueForHigherValues() {
|
||||
assertThat(evaluate("findByAgeGreaterThan", BRAN.age).against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void greaterThanReturnsFalseForLowerValues() {
|
||||
void greaterThanReturnsFalseForLowerValues() {
|
||||
assertThat(evaluate("findByAgeGreaterThan", BRAN.age).against(RICKON)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void afterReturnsTrueForHigherValues() {
|
||||
void afterReturnsTrueForHigherValues() {
|
||||
assertThat(evaluate("findByBirthdayAfter", ROBB.birthday).against(BRAN)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void afterReturnsFalseForLowerValues() {
|
||||
void afterReturnsFalseForLowerValues() {
|
||||
assertThat(evaluate("findByBirthdayAfter", BRAN.birthday).against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void greaterThanEaualsReturnsTrueForHigherValues() {
|
||||
void greaterThanEaualsReturnsTrueForHigherValues() {
|
||||
assertThat(evaluate("findByAgeGreaterThanEqual", BRAN.age).against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void greaterThanEqualsReturnsTrueForEqualValues() {
|
||||
void greaterThanEqualsReturnsTrueForEqualValues() {
|
||||
assertThat(evaluate("findByAgeGreaterThanEqual", BRAN.age).against(BRAN)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void greaterThanEqualsReturnsFalseForLowerValues() {
|
||||
void greaterThanEqualsReturnsFalseForLowerValues() {
|
||||
assertThat(evaluate("findByAgeGreaterThanEqual", BRAN.age).against(RICKON)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void lessThanReturnsTrueForHigherValues() {
|
||||
void lessThanReturnsTrueForHigherValues() {
|
||||
assertThat(evaluate("findByAgeLessThan", BRAN.age).against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void lessThanReturnsFalseForLowerValues() {
|
||||
void lessThanReturnsFalseForLowerValues() {
|
||||
assertThat(evaluate("findByAgeLessThan", BRAN.age).against(RICKON)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void beforeReturnsTrueForLowerValues() {
|
||||
void beforeReturnsTrueForLowerValues() {
|
||||
assertThat(evaluate("findByBirthdayBefore", BRAN.birthday).against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void beforeReturnsFalseForHigherValues() {
|
||||
void beforeReturnsFalseForHigherValues() {
|
||||
assertThat(evaluate("findByBirthdayBefore", ROBB.birthday).against(BRAN)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void lessThanEaualsReturnsTrueForHigherValues() {
|
||||
void lessThanEaualsReturnsTrueForHigherValues() {
|
||||
assertThat(evaluate("findByAgeLessThanEqual", BRAN.age).against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void lessThanEaualsReturnsTrueForEqualValues() {
|
||||
void lessThanEaualsReturnsTrueForEqualValues() {
|
||||
assertThat(evaluate("findByAgeLessThanEqual", BRAN.age).against(BRAN)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void lessThanEqualsReturnsFalseForLowerValues() {
|
||||
void lessThanEqualsReturnsFalseForLowerValues() {
|
||||
assertThat(evaluate("findByAgeLessThanEqual", BRAN.age).against(RICKON)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void betweenEqualsReturnsTrueForValuesInBetween() {
|
||||
void betweenEqualsReturnsTrueForValuesInBetween() {
|
||||
assertThat(evaluate("findByAgeBetween", BRAN.age, ROBB.age).against(ARYA)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void betweenEqualsReturnsFalseForHigherValues() {
|
||||
void betweenEqualsReturnsFalseForHigherValues() {
|
||||
assertThat(evaluate("findByAgeBetween", BRAN.age, ROBB.age).against(JON)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void betweenEqualsReturnsFalseForLowerValues() {
|
||||
void betweenEqualsReturnsFalseForLowerValues() {
|
||||
assertThat(evaluate("findByAgeBetween", BRAN.age, ROBB.age).against(RICKON)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void connectByAndReturnsTrueWhenAllPropertiesMatching() {
|
||||
void connectByAndReturnsTrueWhenAllPropertiesMatching() {
|
||||
assertThat(evaluate("findByAgeGreaterThanAndLastname", BRAN.age, JON.lastname).against(JON)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void connectByAndReturnsFalseWhenOnlyFewPropertiesMatch() {
|
||||
void connectByAndReturnsFalseWhenOnlyFewPropertiesMatch() {
|
||||
assertThat(evaluate("findByAgeGreaterThanAndLastname", BRAN.age, JON.lastname).against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void connectByOrReturnsTrueWhenOnlyFewPropertiesMatch() {
|
||||
void connectByOrReturnsTrueWhenOnlyFewPropertiesMatch() {
|
||||
assertThat(evaluate("findByAgeGreaterThanOrLastname", BRAN.age, JON.lastname).against(ROBB)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void connectByOrReturnsTrueWhenAllPropertiesMatch() {
|
||||
void connectByOrReturnsTrueWhenAllPropertiesMatch() {
|
||||
assertThat(evaluate("findByAgeGreaterThanOrLastname", BRAN.age, JON.lastname).against(JON)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void regexReturnsTrueWhenMatching() {
|
||||
void regexReturnsTrueWhenMatching() {
|
||||
assertThat(evaluate("findByLastnameMatches", "^s.*w$").against(JON)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void regexReturnsFalseWhenNotMatching() {
|
||||
void regexReturnsFalseWhenNotMatching() {
|
||||
assertThat(evaluate("findByLastnameMatches", "^s.*w$").against(ROBB)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void inReturnsMatchCorrectly() {
|
||||
void inReturnsMatchCorrectly() {
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(ROBB.firstname);
|
||||
@@ -277,7 +277,7 @@ public class SpelQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void inNotMatchingReturnsCorrectly() {
|
||||
void inNotMatchingReturnsCorrectly() {
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(ROBB.firstname);
|
||||
@@ -286,7 +286,7 @@ public class SpelQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void inWithNullCompareValuesCorrectly() {
|
||||
void inWithNullCompareValuesCorrectly() {
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(null);
|
||||
@@ -295,7 +295,7 @@ public class SpelQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void inWithNullSourceValuesMatchesCorrectly() {
|
||||
void inWithNullSourceValuesMatchesCorrectly() {
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(ROBB.firstname);
|
||||
@@ -304,7 +304,7 @@ public class SpelQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void inMatchesNullValuesCorrectly() {
|
||||
void inMatchesNullValuesCorrectly() {
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(null);
|
||||
@@ -313,7 +313,7 @@ public class SpelQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-185
|
||||
public void noDerivedQueryArgumentsMatchesAlways() {
|
||||
void noDerivedQueryArgumentsMatchesAlways() {
|
||||
|
||||
assertThat(evaluate("findBy").against(JON)).isTrue();
|
||||
assertThat(evaluate("findBy").against(null)).isTrue();
|
||||
@@ -420,11 +420,11 @@ public class SpelQueryCreatorUnitTests {
|
||||
SpelExpression expression;
|
||||
Object candidate;
|
||||
|
||||
public Evaluation(SpelExpression expression) {
|
||||
Evaluation(SpelExpression expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public Boolean against(Object candidate) {
|
||||
Boolean against(Object candidate) {
|
||||
this.candidate = candidate;
|
||||
return evaluate();
|
||||
}
|
||||
@@ -436,7 +436,7 @@ public class SpelQueryCreatorUnitTests {
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Person {
|
||||
public static class Person {
|
||||
|
||||
private @Id String id;
|
||||
private String firstname, lastname;
|
||||
@@ -446,23 +446,23 @@ public class SpelQueryCreatorUnitTests {
|
||||
|
||||
public Person() {}
|
||||
|
||||
public Person(String firstname, int age) {
|
||||
Person(String firstname, int age) {
|
||||
super();
|
||||
this.firstname = firstname;
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public Person skinChanger(boolean isSkinChanger) {
|
||||
Person skinChanger(boolean isSkinChanger) {
|
||||
this.isSkinChanger = isSkinChanger;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Person named(String lastname) {
|
||||
Person named(String lastname) {
|
||||
this.lastname = lastname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Person bornAt(Date date) {
|
||||
Person bornAt(Date date) {
|
||||
this.birthday = date;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.data.keyvalue.repository.support;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.keyvalue.repository.support.KeyValueQuerydslUtils.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.domain.Sort.NullHandling;
|
||||
@@ -39,30 +39,30 @@ import com.querydsl.core.types.dsl.PathBuilder;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class KeyValueQuerydslUtilsUnitTests {
|
||||
class KeyValueQuerydslUtilsUnitTests {
|
||||
|
||||
private EntityPath<Person> path;
|
||||
private PathBuilder<Person> builder;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.path = SimpleEntityPathResolver.INSTANCE.createPath(Person.class);
|
||||
this.builder = new PathBuilder<>(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierThrowsExceptioOnNullPathBuilder() {
|
||||
void toOrderSpecifierThrowsExceptioOnNullPathBuilder() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> toOrderSpecifier(Sort.by("firstname"), null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525, DATAKV-197
|
||||
public void toOrderSpecifierReturnsEmptyArrayWhenSortIsUnsorted() {
|
||||
void toOrderSpecifierReturnsEmptyArrayWhenSortIsUnsorted() {
|
||||
assertThat(toOrderSpecifier(Sort.unsorted(), builder)).hasSize(0);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSimpleAscSortCorrectly() {
|
||||
void toOrderSpecifierConvertsSimpleAscSortCorrectly() {
|
||||
|
||||
Sort sort = Sort.by(Direction.ASC, "firstname");
|
||||
|
||||
@@ -72,7 +72,7 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSimpleDescSortCorrectly() {
|
||||
void toOrderSpecifierConvertsSimpleDescSortCorrectly() {
|
||||
|
||||
Sort sort = Sort.by(Direction.DESC, "firstname");
|
||||
|
||||
@@ -82,7 +82,7 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSortCorrectlyAndRetainsArgumentOrder() {
|
||||
void toOrderSpecifierConvertsSortCorrectlyAndRetainsArgumentOrder() {
|
||||
|
||||
Sort sort = Sort.by(Direction.DESC, "firstname").and(Sort.by(Direction.ASC, "age"));
|
||||
|
||||
@@ -92,7 +92,7 @@ public class KeyValueQuerydslUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void toOrderSpecifierConvertsSortWithNullHandlingCorrectly() {
|
||||
void toOrderSpecifierConvertsSortWithNullHandlingCorrectly() {
|
||||
|
||||
Sort sort = Sort.by(new Sort.Order(Direction.DESC, "firstname", NullHandling.NULLS_LAST));
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.data.keyvalue.repository.support;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.keyvalue.core.KeyValueOperations;
|
||||
import org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery;
|
||||
@@ -33,34 +33,34 @@ import org.springframework.data.repository.query.parser.AbstractQueryCreator;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class KeyValueRepositoryFactoryBeanUnitTests {
|
||||
class KeyValueRepositoryFactoryBeanUnitTests {
|
||||
|
||||
KeyValueRepositoryFactoryBean<?, ?, ?> factoryBean;
|
||||
private KeyValueRepositoryFactoryBean<?, ?, ?> factoryBean;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.factoryBean = new KeyValueRepositoryFactoryBean<Repository<Object, Object>, Object, Object>(
|
||||
SampleRepository.class);
|
||||
}
|
||||
|
||||
@Test // DATAKV-123
|
||||
public void rejectsNullKeyValueOperations() {
|
||||
void rejectsNullKeyValueOperations() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factoryBean.setKeyValueOperations(null));
|
||||
}
|
||||
|
||||
@Test // DATAKV-123
|
||||
public void rejectsNullQueryCreator() {
|
||||
void rejectsNullQueryCreator() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factoryBean.setQueryCreator(null));
|
||||
}
|
||||
|
||||
@Test // DATAKV-123
|
||||
public void rejectsUninitializedInstance() {
|
||||
void rejectsUninitializedInstance() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factoryBean.afterPropertiesSet());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test // DATAKV-123
|
||||
public void rejectsInstanceWithoutKeyValueOperations() {
|
||||
void rejectsInstanceWithoutKeyValueOperations() {
|
||||
|
||||
Class<? extends AbstractQueryCreator<?, ?>> creatorType = (Class<? extends AbstractQueryCreator<?, ?>>) mock(
|
||||
AbstractQueryCreator.class).getClass();
|
||||
@@ -71,7 +71,7 @@ public class KeyValueRepositoryFactoryBeanUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-123
|
||||
public void rejectsInstanceWithoutQueryCreator() {
|
||||
void rejectsInstanceWithoutQueryCreator() {
|
||||
|
||||
factoryBean.setKeyValueOperations(mock(KeyValueOperations.class));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factoryBean.afterPropertiesSet());
|
||||
@@ -79,7 +79,7 @@ public class KeyValueRepositoryFactoryBeanUnitTests {
|
||||
|
||||
@Test // DATAKV-123
|
||||
@SuppressWarnings("unchecked")
|
||||
public void createsRepositoryFactory() {
|
||||
void createsRepositoryFactory() {
|
||||
|
||||
Class<? extends AbstractQueryCreator<?, ?>> creatorType = (Class<? extends AbstractQueryCreator<?, ?>>) mock(
|
||||
AbstractQueryCreator.class).getClass();
|
||||
@@ -93,7 +93,7 @@ public class KeyValueRepositoryFactoryBeanUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-112
|
||||
public void rejectsNullQueryType() {
|
||||
void rejectsNullQueryType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factoryBean.setQueryType(null));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -47,18 +47,18 @@ import org.springframework.data.repository.CrudRepository;
|
||||
*/
|
||||
public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUnitTests.PersonRepository> {
|
||||
|
||||
protected static final Person CERSEI = new Person("cersei", 19);
|
||||
protected static final Person JAIME = new Person("jaime", 19);
|
||||
protected static final Person TYRION = new Person("tyrion", 17);
|
||||
static final Person CERSEI = new Person("cersei", 19);
|
||||
static final Person JAIME = new Person("jaime", 19);
|
||||
static final Person TYRION = new Person("tyrion", 17);
|
||||
|
||||
protected static List<Person> LENNISTERS = Arrays.asList(CERSEI, JAIME, TYRION);
|
||||
static List<Person> LENNISTERS = Arrays.asList(CERSEI, JAIME, TYRION);
|
||||
|
||||
protected final QPerson person = QPerson.person;
|
||||
|
||||
protected T repository;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
|
||||
KeyValueOperations operations = new KeyValueTemplate(new MapKeyValueAdapter());
|
||||
KeyValueRepositoryFactory keyValueRepositoryFactory = createKeyValueRepositoryFactory(operations);
|
||||
@@ -67,7 +67,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findBy() {
|
||||
void findBy() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATAKV-137
|
||||
public void findByFirstname() {
|
||||
void findByFirstname() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -84,7 +84,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525, DATAKV-137
|
||||
public void combindedFindUsingAnd() {
|
||||
void combindedFindUsingAnd() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findPage() {
|
||||
void findPage() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -109,7 +109,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findByConnectingOr() {
|
||||
void findByConnectingOr() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -117,7 +117,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525, DATAKV-137
|
||||
public void singleEntityExecution() {
|
||||
void singleEntityExecution() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -126,7 +126,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllShouldRespectSort() {
|
||||
void findAllShouldRespectSort() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void derivedFinderShouldRespectSort() {
|
||||
void derivedFinderShouldRespectSort() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -146,7 +146,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATAKV-121
|
||||
public void projectsResultToInterface() {
|
||||
void projectsResultToInterface() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATAKV-121
|
||||
public void projectsResultToDynamicInterface() {
|
||||
void projectsResultToDynamicInterface() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -168,7 +168,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void findsByValueInCollectionCorrectly() {
|
||||
void findsByValueInCollectionCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -179,7 +179,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void findsByValueInCollectionCorrectlyWhenTargetPathContainsNullValue() {
|
||||
void findsByValueInCollectionCorrectlyWhenTargetPathContainsNullValue() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
repository.save(new Person(null, 10));
|
||||
@@ -191,7 +191,7 @@ public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUn
|
||||
}
|
||||
|
||||
@Test // DATAKV-169
|
||||
public void findsByValueInCollectionCorrectlyWhenTargetPathAndCollectionContainNullValue() {
|
||||
void findsByValueInCollectionCorrectlyWhenTargetPathAndCollectionContainNullValue() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
|
||||
@@ -22,15 +22,15 @@ import lombok.Data;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.util.CloseableIterator;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class MapKeyValueAdapterUnitTests {
|
||||
class MapKeyValueAdapterUnitTests {
|
||||
|
||||
private static final String COLLECTION_1 = "collection-1";
|
||||
private static final String COLLECTION_2 = "collection-2";
|
||||
@@ -41,79 +41,79 @@ public class MapKeyValueAdapterUnitTests {
|
||||
|
||||
private MapKeyValueAdapter adapter;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
this.adapter = new MapKeyValueAdapter();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void putShouldThrowExceptionWhenAddingNullId() {
|
||||
void putShouldThrowExceptionWhenAddingNullId() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> adapter.put(null, object1, COLLECTION_1));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void putShouldThrowExceptionWhenCollectionIsNullValue() {
|
||||
void putShouldThrowExceptionWhenCollectionIsNullValue() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> adapter.put("1", object1, null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void putReturnsNullWhenNoObjectForIdPresent() {
|
||||
void putReturnsNullWhenNoObjectForIdPresent() {
|
||||
assertThat(adapter.put("1", object1, COLLECTION_1)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void putShouldReturnPreviousObjectForIdWhenAddingNewOneWithSameIdPresent() {
|
||||
void putShouldReturnPreviousObjectForIdWhenAddingNewOneWithSameIdPresent() {
|
||||
|
||||
adapter.put("1", object1, COLLECTION_1);
|
||||
assertThat(adapter.put("1", object2, COLLECTION_1)).isEqualTo(object1);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void containsShouldThrowExceptionWhenIdIsNull() {
|
||||
void containsShouldThrowExceptionWhenIdIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> adapter.contains(null, COLLECTION_1));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void containsShouldThrowExceptionWhenTypeIsNull() {
|
||||
void containsShouldThrowExceptionWhenTypeIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> adapter.contains("", null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void containsShouldReturnFalseWhenNoElementsPresent() {
|
||||
void containsShouldReturnFalseWhenNoElementsPresent() {
|
||||
assertThat(adapter.contains("1", COLLECTION_1)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void containShouldReturnTrueWhenElementWithIdPresent() {
|
||||
void containShouldReturnTrueWhenElementWithIdPresent() {
|
||||
|
||||
adapter.put("1", object1, COLLECTION_1);
|
||||
assertThat(adapter.contains("1", COLLECTION_1)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void getShouldReturnNullWhenNoElementWithIdPresent() {
|
||||
void getShouldReturnNullWhenNoElementWithIdPresent() {
|
||||
assertThat(adapter.get("1", COLLECTION_1)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void getShouldReturnElementWhenMatchingIdPresent() {
|
||||
void getShouldReturnElementWhenMatchingIdPresent() {
|
||||
|
||||
adapter.put("1", object1, COLLECTION_1);
|
||||
assertThat(adapter.get("1", COLLECTION_1)).isEqualTo(object1);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void getShouldThrowExceptionWhenIdIsNull() {
|
||||
void getShouldThrowExceptionWhenIdIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> adapter.get(null, COLLECTION_1));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void getShouldThrowExceptionWhenTypeIsNull() {
|
||||
void getShouldThrowExceptionWhenTypeIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> adapter.get("1", null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void getAllOfShouldReturnAllValuesOfGivenCollection() {
|
||||
void getAllOfShouldReturnAllValuesOfGivenCollection() {
|
||||
|
||||
adapter.put("1", object1, COLLECTION_1);
|
||||
adapter.put("2", object2, COLLECTION_1);
|
||||
@@ -123,24 +123,24 @@ public class MapKeyValueAdapterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void getAllOfShouldThrowExceptionWhenTypeIsNull() {
|
||||
void getAllOfShouldThrowExceptionWhenTypeIsNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> adapter.getAllOf(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteShouldReturnNullWhenGivenIdThatDoesNotExist() {
|
||||
void deleteShouldReturnNullWhenGivenIdThatDoesNotExist() {
|
||||
assertThat(adapter.delete("1", COLLECTION_1)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void deleteShouldReturnDeletedObject() {
|
||||
void deleteShouldReturnDeletedObject() {
|
||||
|
||||
adapter.put("1", object1, COLLECTION_1);
|
||||
assertThat(adapter.delete("1", COLLECTION_1)).isEqualTo(object1);
|
||||
}
|
||||
|
||||
@Test // DATAKV-99
|
||||
public void scanShouldIterateOverAvailableEntries() {
|
||||
void scanShouldIterateOverAvailableEntries() {
|
||||
|
||||
adapter.put("1", object1, COLLECTION_1);
|
||||
adapter.put("2", object2, COLLECTION_1);
|
||||
@@ -153,12 +153,12 @@ public class MapKeyValueAdapterUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-99
|
||||
public void scanShouldReturnEmptyIteratorWhenNoElementsAvailable() {
|
||||
void scanShouldReturnEmptyIteratorWhenNoElementsAvailable() {
|
||||
assertThat(adapter.entries(COLLECTION_1).hasNext()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAKV-99
|
||||
public void scanDoesNotMixResultsFromMultipleKeyspaces() {
|
||||
void scanDoesNotMixResultsFromMultipleKeyspaces() {
|
||||
|
||||
adapter.put("1", object1, COLLECTION_1);
|
||||
adapter.put("2", object2, COLLECTION_2);
|
||||
|
||||
@@ -21,8 +21,8 @@ import static org.assertj.core.api.Assumptions.*;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -50,13 +50,13 @@ import com.google.common.collect.Lists;
|
||||
*/
|
||||
public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitTests<QPersonRepository> {
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
assumeThat(Version.javaVersion().toString()).startsWith("1.8");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findOneIsExecutedCorrectly() {
|
||||
void findOneIsExecutedCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllIsExecutedCorrectly() {
|
||||
void findAllIsExecutedCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findWithPaginationWorksCorrectly() {
|
||||
void findWithPaginationWorksCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
Page<Person> page1 = repository.findAll(QPerson.person.age.eq(CERSEI.getAge()), PageRequest.of(0, 1));
|
||||
@@ -91,7 +91,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllUsingOrderSpecifierWorksCorrectly() {
|
||||
void findAllUsingOrderSpecifierWorksCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllUsingPageableWithSortWorksCorrectly() {
|
||||
void findAllUsingPageableWithSortWorksCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -113,7 +113,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void findAllUsingPagableWithQSortWorksCorrectly() {
|
||||
void findAllUsingPagableWithQSortWorksCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATAKV-90
|
||||
public void findAllWithOrderSpecifierWorksCorrectly() {
|
||||
void findAllWithOrderSpecifierWorksCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -134,12 +134,12 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATAKV-90, DATAKV-197
|
||||
public void findAllShouldRequireSort() {
|
||||
void findAllShouldRequireSort() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> repository.findAll((QSort) null));
|
||||
}
|
||||
|
||||
@Test // DATAKV-90, DATAKV-197
|
||||
public void findAllShouldAllowUnsortedFindAll() {
|
||||
void findAllShouldAllowUnsortedFindAll() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -149,7 +149,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATAKV-95
|
||||
public void executesExistsCorrectly() {
|
||||
void executesExistsCorrectly() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -157,7 +157,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATAKV-96
|
||||
public void shouldSupportFindAllWithPredicateAndSort() {
|
||||
void shouldSupportFindAllWithPredicateAndSort() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
@@ -170,7 +170,7 @@ public class QuerydslKeyValueRepositoryUnitTests extends AbstractRepositoryUnitT
|
||||
}
|
||||
|
||||
@Test // DATAKV-179
|
||||
public void throwsExceptionIfMoreThanOneResultIsFound() {
|
||||
void throwsExceptionIfMoreThanOneResultIsFound() {
|
||||
|
||||
repository.saveAll(LENNISTERS);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -38,10 +38,10 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class MapRepositoriesConfigurationExtensionIntegrationTests {
|
||||
class MapRepositoriesConfigurationExtensionIntegrationTests {
|
||||
|
||||
@Test // DATAKV-86
|
||||
public void registersDefaultTemplateIfReferenceNotCustomized() {
|
||||
void registersDefaultTemplateIfReferenceNotCustomized() {
|
||||
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MapRepositoriesConfigurationExtensionIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-86
|
||||
public void doesNotRegisterDefaulttemplateIfReferenceIsCustomized() {
|
||||
void doesNotRegisterDefaulttemplateIfReferenceIsCustomized() {
|
||||
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
ConfigWithCustomTemplateReference.class);
|
||||
@@ -62,13 +62,13 @@ public class MapRepositoriesConfigurationExtensionIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // DATAKV-87
|
||||
public void considersMapTypeConfiguredOnAnnotation() {
|
||||
void considersMapTypeConfiguredOnAnnotation() {
|
||||
assertKeyValueTemplateWithAdapterFor(ConcurrentSkipListMap.class,
|
||||
new AnnotationConfigApplicationContext(ConfigWithCustomizedMapType.class));
|
||||
}
|
||||
|
||||
@Test // DATAKV-87
|
||||
public void doesNotConsiderMapConfiguredIfTemplateIsPresent() {
|
||||
void doesNotConsiderMapConfiguredIfTemplateIsPresent() {
|
||||
assertKeyValueTemplateWithAdapterFor(ConcurrentHashMap.class, new AnnotationConfigApplicationContext(
|
||||
ConfigWithCustomizedMapTypeAndExplicitDefinitionOfKeyValueTemplate.class));
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link MapRepositoriesRegistrar} with complete defaulting.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class MapRepositoryRegistrarWithFullDefaultingIntegrationTests {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MapRepositoryRegistrarWithFullDefaultingIntegrationTests {
|
||||
@Autowired PersonRepository repo;
|
||||
|
||||
@Test // DATAKV-86
|
||||
public void shouldEnableMapRepositoryCorrectly() {
|
||||
void shouldEnableMapRepositoryCorrectly() {
|
||||
assertThat(repo).isNotNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.data.keyvalue.core.KeyValueTemplate;
|
||||
import org.springframework.data.map.MapKeyValueAdapter;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link MapRepositoriesRegistrar} with complete defaulting.
|
||||
@@ -41,7 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration
|
||||
public class MapRepositoryRegistrarWithTemplateDefinitionIntegrationTests {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MapRepositoryRegistrarWithTemplateDefinitionIntegrationTests {
|
||||
@Autowired PersonRepository repo;
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void shouldEnableMapRepositoryCorrectly() {
|
||||
void shouldEnableMapRepositoryCorrectly() {
|
||||
assertThat(repo).isNotNull();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user