DATACMNS-1718 - Migrate tests to JUnit 5.
This commit is contained in:
@@ -17,7 +17,7 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.annotation.Persistent;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -21,11 +21,12 @@ import static org.mockito.Mockito.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
|
||||
import org.springframework.data.querydsl.EntityPathResolver;
|
||||
@@ -37,13 +38,13 @@ import org.springframework.data.querydsl.SimpleEntityPathResolver;
|
||||
* @author Oliver Gierke
|
||||
* @soundtrack Dave Matthews Band - Shotgun (DMB Live 25)
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class BeanLookupUnitTests {
|
||||
|
||||
@Mock ListableBeanFactory beanFactory;
|
||||
Map<String, EntityPathResolver> beans;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
|
||||
this.beans = new HashMap<>();
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.mapping.Person;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests to reproduce issues reported in DATACMNS-511.
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.NotReadablePropertyException;
|
||||
import org.springframework.beans.NotWritablePropertyException;
|
||||
|
||||
@@ -21,8 +21,8 @@ import static org.assertj.core.api.Assumptions.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -35,19 +35,19 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public class KotlinReflectionUtilsUnitTests {
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@BeforeEach
|
||||
void before() {
|
||||
assumeThat(Version.javaVersion()).isLessThan(Version.parse("9.0"));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1508
|
||||
public void classShouldLoadWithKotlin() {
|
||||
void classShouldLoadWithKotlin() {
|
||||
assertThat(KotlinDetector.isKotlinPresent()).isTrue();
|
||||
assertThat(KotlinReflectionUtils.isSupportedKotlinClass(TypeCreatingSyntheticClass.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1508
|
||||
public void classShouldLoadWithoutKotlin() throws Exception {
|
||||
void classShouldLoadWithoutKotlin() throws Exception {
|
||||
runTest("loadClassWithoutKotlin");
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class KotlinReflectionUtilsUnitTests {
|
||||
assertThat(KotlinReflectionUtils.isSupportedKotlinClass(TypeCreatingSyntheticClass.class)).isFalse();
|
||||
}
|
||||
|
||||
protected void runTest(String testName)
|
||||
void runTest(String testName)
|
||||
throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException {
|
||||
|
||||
KotlinExcludingURLClassLoader classLoader = new KotlinExcludingURLClassLoader(
|
||||
@@ -69,7 +69,7 @@ public class KotlinReflectionUtilsUnitTests {
|
||||
}
|
||||
|
||||
static class KotlinExcludingURLClassLoader extends URLClassLoader {
|
||||
public KotlinExcludingURLClassLoader(URL[] urls) {
|
||||
KotlinExcludingURLClassLoader(URL[] urls) {
|
||||
super(urls, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ import static org.mockito.Mockito.*;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Lazy}.
|
||||
@@ -32,14 +32,14 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class LazyUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class LazyUnitTests {
|
||||
|
||||
@Mock Supplier<String> supplier;
|
||||
@Mock Supplier<Optional<String>> optionalSupplier;
|
||||
|
||||
@Test
|
||||
public void createsLazyOptional() {
|
||||
void createsLazyOptional() {
|
||||
|
||||
doReturn(Optional.empty()).when(optionalSupplier).get();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class LazyUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsLazyFromValue() {
|
||||
void createsLazyFromValue() {
|
||||
|
||||
Object value = new Object();
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LazyUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsLastValueInChain() {
|
||||
void returnsLastValueInChain() {
|
||||
|
||||
Object reference = new Object();
|
||||
|
||||
@@ -68,7 +68,7 @@ public class LazyUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsCachedInstanceOnMultipleAccesses() {
|
||||
void returnsCachedInstanceOnMultipleAccesses() {
|
||||
|
||||
Lazy<Object> lazy = Lazy.of(() -> new Object());
|
||||
|
||||
@@ -76,24 +76,24 @@ public class LazyUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsNullValueLookup() {
|
||||
void rejectsNullValueLookup() {
|
||||
|
||||
assertThatExceptionOfType(IllegalStateException.class) //
|
||||
.isThrownBy(() -> Lazy.of(() -> null).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowsNullableValueLookupViaOptional() {
|
||||
void allowsNullableValueLookupViaOptional() {
|
||||
assertThat(Lazy.of(() -> null).getOptional()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1556
|
||||
public void allowsNullableValue() {
|
||||
void allowsNullableValue() {
|
||||
assertThat(Lazy.of(() -> null).getNullable()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoresElseIfValuePresent() {
|
||||
void ignoresElseIfValuePresent() {
|
||||
|
||||
Object first = new Object();
|
||||
Object second = new Object();
|
||||
@@ -106,7 +106,7 @@ public class LazyUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsElseValue() {
|
||||
void returnsElseValue() {
|
||||
|
||||
Object reference = new Object();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.util.MethodInvocationRecorder.Recorded;
|
||||
|
||||
/**
|
||||
@@ -30,19 +30,19 @@ import org.springframework.data.util.MethodInvocationRecorder.Recorded;
|
||||
* @author Oliver Gierke
|
||||
* @soundtrack The Intersphere - Don't Think Twice (The Grand Delusion)
|
||||
*/
|
||||
public class MethodInvocationRecorderUnitTests {
|
||||
class MethodInvocationRecorderUnitTests {
|
||||
|
||||
Recorded<Foo> recorder = MethodInvocationRecorder.forProxyOf(Foo.class);
|
||||
private Recorded<Foo> recorder = MethodInvocationRecorder.forProxyOf(Foo.class);
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void rejectsFinalTypes() {
|
||||
void rejectsFinalTypes() {
|
||||
|
||||
assertThatExceptionOfType(IllegalArgumentException.class) //
|
||||
.isThrownBy(() -> MethodInvocationRecorder.forProxyOf(FinalType.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void createsPropertyPathForSimpleMethodReference() {
|
||||
void createsPropertyPathForSimpleMethodReference() {
|
||||
|
||||
Recorded<Bar> wrapper = recorder.record(Foo::getBar);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MethodInvocationRecorderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void createsPropertyPathForNestedMethodReference() {
|
||||
void createsPropertyPathForNestedMethodReference() {
|
||||
|
||||
Recorded<FooBar> wrapper = recorder.record(Foo::getBar).record(Bar::getFooBar);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MethodInvocationRecorderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void createsPropertyPathForNestedCall() {
|
||||
void createsPropertyPathForNestedCall() {
|
||||
|
||||
Recorded<FooBar> wrapper = recorder.record((Foo source) -> source.getBar().getFooBar());
|
||||
|
||||
@@ -66,7 +66,7 @@ public class MethodInvocationRecorderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void usesCustomPropertyNamingStrategy() {
|
||||
void usesCustomPropertyNamingStrategy() {
|
||||
|
||||
Recorded<Bar> recorded = MethodInvocationRecorder.forProxyOf(Foo.class).record(Foo::getBar);
|
||||
|
||||
@@ -74,12 +74,12 @@ public class MethodInvocationRecorderUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void registersLookupToFinalType() {
|
||||
void registersLookupToFinalType() {
|
||||
assertThat(recorder.record(Foo::getName).getPropertyPath()).hasValue("name");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1449
|
||||
public void recordsInvocationOnInterface() {
|
||||
void recordsInvocationOnInterface() {
|
||||
|
||||
Recorded<Sample> recorder = MethodInvocationRecorder.forProxyOf(Sample.class);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.data.util.nonnull.NullableAnnotatedType;
|
||||
import org.springframework.data.util.nonnull.packagelevel.NonNullOnPackage;
|
||||
@@ -34,10 +34,10 @@ import org.springframework.util.ReflectionUtils;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class NullableUtilsUnitTests {
|
||||
class NullableUtilsUnitTests {
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void packageAnnotatedShouldConsiderNonNullAnnotation() {
|
||||
void packageAnnotatedShouldConsiderNonNullAnnotation() {
|
||||
|
||||
Method method = ReflectionUtils.findMethod(NonNullOnPackage.class, "nonNullReturnValue");
|
||||
|
||||
@@ -47,42 +47,42 @@ public class NullableUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void packageAnnotatedShouldConsiderNonNullAnnotationForClass() {
|
||||
void packageAnnotatedShouldConsiderNonNullAnnotationForClass() {
|
||||
|
||||
assertThat(NullableUtils.isNonNull(NonNullOnPackage.class, ElementType.PARAMETER)).isTrue();
|
||||
assertThat(NullableUtils.isNonNull(NonNullOnPackage.class, ElementType.PACKAGE)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void packageAnnotatedShouldConsiderNonNullAnnotationForMethod() {
|
||||
void packageAnnotatedShouldConsiderNonNullAnnotationForMethod() {
|
||||
|
||||
assertThat(NullableUtils.isNonNull(NonNullOnPackage.class, ElementType.PARAMETER)).isTrue();
|
||||
assertThat(NullableUtils.isNonNull(NonNullOnPackage.class, ElementType.PACKAGE)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void shouldConsiderJsr305NonNullParameters() {
|
||||
void shouldConsiderJsr305NonNullParameters() {
|
||||
|
||||
assertThat(NullableUtils.isNonNull(NonNullableParameters.class, ElementType.PARAMETER)).isTrue();
|
||||
assertThat(NullableUtils.isNonNull(NonNullableParameters.class, ElementType.FIELD)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void shouldConsiderJsr305NonNullAnnotation() {
|
||||
void shouldConsiderJsr305NonNullAnnotation() {
|
||||
|
||||
assertThat(NullableUtils.isNonNull(Jsr305NonnullAnnotatedType.class, ElementType.PARAMETER)).isTrue();
|
||||
assertThat(NullableUtils.isNonNull(Jsr305NonnullAnnotatedType.class, ElementType.FIELD)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void shouldConsiderNonAnnotatedTypeNullable() {
|
||||
void shouldConsiderNonAnnotatedTypeNullable() {
|
||||
|
||||
assertThat(NullableUtils.isNonNull(NonAnnotatedType.class, ElementType.PARAMETER)).isFalse();
|
||||
assertThat(NullableUtils.isNonNull(NonAnnotatedType.class, ElementType.FIELD)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void shouldConsiderParametersWithoutNullableAnnotation() {
|
||||
void shouldConsiderParametersWithoutNullableAnnotation() {
|
||||
|
||||
Method method = ReflectionUtils.findMethod(NullableAnnotatedType.class, "nonNullMethod", String.class);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class NullableUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void shouldConsiderParametersNullableAnnotation() {
|
||||
void shouldConsiderParametersNullableAnnotation() {
|
||||
|
||||
Method method = ReflectionUtils.findMethod(NullableAnnotatedType.class, "nullableReturn");
|
||||
|
||||
@@ -102,7 +102,7 @@ public class NullableUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void shouldConsiderParametersJsr305NullableMetaAnnotation() {
|
||||
void shouldConsiderParametersJsr305NullableMetaAnnotation() {
|
||||
|
||||
Method method = ReflectionUtils.findMethod(NullableAnnotatedType.class, "jsr305NullableReturn");
|
||||
|
||||
@@ -110,7 +110,7 @@ public class NullableUtilsUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1154
|
||||
public void shouldConsiderParametersJsr305NonnullAnnotation() {
|
||||
void shouldConsiderParametersJsr305NonnullAnnotation() {
|
||||
|
||||
Method method = ReflectionUtils.findMethod(NullableAnnotatedType.class, "jsr305NullableReturnWhen");
|
||||
|
||||
|
||||
@@ -17,17 +17,17 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Pair}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class PairUnitTests {
|
||||
class PairUnitTests {
|
||||
|
||||
@Test // DATACMNS-790
|
||||
public void setsUpSimpleInstance() {
|
||||
void setsUpSimpleInstance() {
|
||||
|
||||
Pair<Integer, Integer> pair = Pair.of(1, 2);
|
||||
|
||||
@@ -36,17 +36,17 @@ public class PairUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-790
|
||||
public void rejectsNullFirstElement() {
|
||||
void rejectsNullFirstElement() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Pair.of(null, 1));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-790
|
||||
public void rejectsNullSecondElement() {
|
||||
void rejectsNullSecondElement() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Pair.of(1, null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-790
|
||||
public void hasCorrectEquals() {
|
||||
void hasCorrectEquals() {
|
||||
|
||||
Pair<Integer, Integer> first = Pair.of(1, 2);
|
||||
Pair<Integer, Integer> second = Pair.of(1, 2);
|
||||
@@ -57,7 +57,7 @@ public class PairUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-790
|
||||
public void hasCorrectHashCode() {
|
||||
void hasCorrectHashCode() {
|
||||
|
||||
Pair<Integer, Integer> first = Pair.of(1, 2);
|
||||
Pair<Integer, Integer> second = Pair.of(1, 2);
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,11 +27,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
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.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ParameterizedTypeInformation}.
|
||||
@@ -39,18 +41,19 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ParameterizedTypeInformationUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
class ParameterizedTypeInformationUnitTests {
|
||||
|
||||
@Mock ParameterizedType one;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
when(one.getActualTypeArguments()).thenReturn(new Type[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void considersTypeInformationsWithDifferingParentsNotEqual() {
|
||||
void considersTypeInformationsWithDifferingParentsNotEqual() {
|
||||
|
||||
TypeDiscoverer<String> stringParent = new TypeDiscoverer<>(String.class, emptyMap());
|
||||
TypeDiscoverer<Object> objectParent = new TypeDiscoverer<>(Object.class, emptyMap());
|
||||
@@ -62,7 +65,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void considersTypeInformationsWithSameParentsNotEqual() {
|
||||
void considersTypeInformationsWithSameParentsNotEqual() {
|
||||
|
||||
TypeDiscoverer<String> stringParent = new TypeDiscoverer<>(String.class, emptyMap());
|
||||
|
||||
@@ -73,7 +76,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-88
|
||||
public void resolvesMapValueTypeCorrectly() {
|
||||
void resolvesMapValueTypeCorrectly() {
|
||||
|
||||
TypeInformation<Foo> type = ClassTypeInformation.from(Foo.class);
|
||||
TypeInformation<?> propertyType = type.getProperty("param");
|
||||
@@ -90,14 +93,14 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-446
|
||||
public void createsToStringRepresentation() {
|
||||
void createsToStringRepresentation() {
|
||||
|
||||
assertThat(from(Foo.class).getProperty("param").toString())
|
||||
.isEqualTo("org.springframework.data.util.ParameterizedTypeInformationUnitTests$Localized<java.lang.String>");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-485
|
||||
public void hashCodeShouldBeConsistentWithEqualsForResolvedTypes() {
|
||||
void hashCodeShouldBeConsistentWithEqualsForResolvedTypes() {
|
||||
|
||||
TypeInformation<?> first = from(First.class).getProperty("property");
|
||||
TypeInformation<?> second = from(Second.class).getProperty("property");
|
||||
@@ -109,7 +112,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-485
|
||||
public void getActualTypeShouldNotUnwrapParameterizedTypes() {
|
||||
void getActualTypeShouldNotUnwrapParameterizedTypes() {
|
||||
|
||||
TypeInformation<?> type = from(First.class).getProperty("property");
|
||||
|
||||
@@ -117,7 +120,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-697
|
||||
public void usesLocalGenericInformationOfFields() {
|
||||
void usesLocalGenericInformationOfFields() {
|
||||
|
||||
TypeInformation<NormalizedProfile> information = ClassTypeInformation.from(NormalizedProfile.class);
|
||||
|
||||
@@ -126,7 +129,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-899
|
||||
public void returnsEmptyOptionalMapValueTypeForNonMapProperties() {
|
||||
void returnsEmptyOptionalMapValueTypeForNonMapProperties() {
|
||||
|
||||
TypeInformation<?> typeInformation = ClassTypeInformation.from(Bar.class).getProperty("param");
|
||||
assertThat(typeInformation).isInstanceOf(ParameterizedTypeInformation.class);
|
||||
@@ -134,7 +137,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1135
|
||||
public void prefersLocalGenericsDeclarationOverParentBound() {
|
||||
void prefersLocalGenericsDeclarationOverParentBound() {
|
||||
|
||||
ClassTypeInformation<Candidate> candidate = ClassTypeInformation.from(Candidate.class);
|
||||
|
||||
@@ -145,7 +148,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1196
|
||||
public void detectsNestedGenerics() {
|
||||
void detectsNestedGenerics() {
|
||||
|
||||
TypeInformation<?> myList = ClassTypeInformation.from(EnumGeneric.class).getRequiredProperty("inner.myList");
|
||||
|
||||
@@ -198,13 +201,13 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
T value;
|
||||
}
|
||||
|
||||
class Education {}
|
||||
private class Education {}
|
||||
|
||||
// DATACMNS-1135
|
||||
|
||||
abstract class CandidateInfo {}
|
||||
|
||||
class Responsibility extends CandidateInfo {}
|
||||
private class Responsibility extends CandidateInfo {}
|
||||
|
||||
class Experience extends CandidateInfo {
|
||||
CandidateInfoContainer<Responsibility> responsibilities;
|
||||
@@ -229,7 +232,7 @@ public class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
static class EnumGeneric extends Generic<MyEnum> {}
|
||||
private static class EnumGeneric extends Generic<MyEnum> {}
|
||||
|
||||
public enum MyEnum {
|
||||
E1, E2
|
||||
|
||||
@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ParsingUtils}.
|
||||
|
||||
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.data.util.ProxyUtils.ProxyDetector;
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.data.mapping.model.TypeCreatingSyntheticClassKt;
|
||||
@@ -40,7 +40,7 @@ public class ReflectionUtilsUnitTests {
|
||||
@SuppressWarnings("rawtypes") Constructor constructor;
|
||||
Field reference;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
this.reference = Sample.class.getField("field");
|
||||
this.constructor = ConstructorDetection.class.getConstructor(int.class, String.class);
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Spring Data specific Java {@link Stream} utility methods and classes.
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Streamable}
|
||||
|
||||
@@ -29,31 +29,31 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link TypeDiscoverer}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class TypeDiscovererUnitTests {
|
||||
|
||||
static final Map<TypeVariable<?>, Type> EMPTY_MAP = Collections.emptyMap();
|
||||
private static final Map<TypeVariable<?>, Type> EMPTY_MAP = Collections.emptyMap();
|
||||
|
||||
@Mock Map<TypeVariable<?>, Type> firstMap;
|
||||
@Mock Map<TypeVariable<?>, Type> secondMap;
|
||||
|
||||
@Test
|
||||
public void rejectsNullType() {
|
||||
void rejectsNullType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new TypeDiscoverer<>(null, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotEqualIfTypesDiffer() {
|
||||
void isNotEqualIfTypesDiffer() {
|
||||
|
||||
TypeDiscoverer<Object> objectTypeInfo = new TypeDiscoverer<>(Object.class, EMPTY_MAP);
|
||||
TypeDiscoverer<String> stringTypeInfo = new TypeDiscoverer<>(String.class, EMPTY_MAP);
|
||||
@@ -62,7 +62,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotEqualIfTypeVariableMapsDiffer() {
|
||||
void isNotEqualIfTypeVariableMapsDiffer() {
|
||||
|
||||
assertThat(firstMap.equals(secondMap)).isFalse();
|
||||
|
||||
@@ -73,7 +73,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dealsWithTypesReferencingThemselves() {
|
||||
void dealsWithTypesReferencingThemselves() {
|
||||
|
||||
TypeInformation<SelfReferencing> information = from(SelfReferencing.class);
|
||||
TypeInformation<?> first = information.getProperty("parent").getMapValueType();
|
||||
@@ -83,7 +83,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dealsWithTypesReferencingThemselvesInAMap() {
|
||||
void dealsWithTypesReferencingThemselvesInAMap() {
|
||||
|
||||
TypeInformation<SelfReferencingMap> information = from(SelfReferencingMap.class);
|
||||
TypeInformation<?> property = information.getProperty("map");
|
||||
@@ -92,7 +92,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsComponentAndValueTypesForMapExtensions() {
|
||||
void returnsComponentAndValueTypesForMapExtensions() {
|
||||
|
||||
TypeInformation<?> discoverer = new TypeDiscoverer<>(CustomMap.class, EMPTY_MAP);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsComponentTypeForCollectionExtension() {
|
||||
void returnsComponentTypeForCollectionExtension() {
|
||||
|
||||
TypeDiscoverer<CustomCollection> discoverer = new TypeDiscoverer<>(CustomCollection.class, firstMap);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsComponentTypeForArrays() {
|
||||
void returnsComponentTypeForArrays() {
|
||||
|
||||
TypeDiscoverer<String[]> discoverer = new TypeDiscoverer<>(String[].class, EMPTY_MAP);
|
||||
|
||||
@@ -117,7 +117,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-57
|
||||
public void discoveresConstructorParameterTypesCorrectly() throws NoSuchMethodException, SecurityException {
|
||||
void discoveresConstructorParameterTypesCorrectly() throws NoSuchMethodException, SecurityException {
|
||||
|
||||
TypeDiscoverer<GenericConstructors> discoverer = new TypeDiscoverer<>(GenericConstructors.class, firstMap);
|
||||
Constructor<GenericConstructors> constructor = GenericConstructors.class.getConstructor(List.class, Locale.class);
|
||||
@@ -130,7 +130,7 @@ public class TypeDiscovererUnitTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void returnsNullForComponentAndValueTypesForRawMaps() {
|
||||
void returnsNullForComponentAndValueTypesForRawMaps() {
|
||||
|
||||
TypeDiscoverer<Map> discoverer = new TypeDiscoverer<>(Map.class, EMPTY_MAP);
|
||||
|
||||
@@ -140,7 +140,7 @@ public class TypeDiscovererUnitTests {
|
||||
|
||||
@Test // DATACMNS-167
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void doesNotConsiderTypeImplementingIterableACollection() {
|
||||
void doesNotConsiderTypeImplementingIterableACollection() {
|
||||
|
||||
TypeDiscoverer<Person> discoverer = new TypeDiscoverer<>(Person.class, EMPTY_MAP);
|
||||
TypeInformation reference = from(Address.class);
|
||||
@@ -161,7 +161,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1342, DATACMNS-1430
|
||||
public void considersStreamableToBeCollectionLike() {
|
||||
void considersStreamableToBeCollectionLike() {
|
||||
|
||||
TypeInformation<SomeStreamable> type = from(SomeStreamable.class);
|
||||
|
||||
@@ -170,7 +170,7 @@ public class TypeDiscovererUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1419
|
||||
public void detectsSubTypes() {
|
||||
void detectsSubTypes() {
|
||||
|
||||
ClassTypeInformation<Set> type = from(Set.class);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Version}.
|
||||
@@ -25,10 +25,10 @@ import org.junit.Test;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class VersionUnitTests {
|
||||
class VersionUnitTests {
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void sameVersionsEqualOneDigits() {
|
||||
void sameVersionsEqualOneDigits() {
|
||||
|
||||
Version first = new Version(6);
|
||||
Version second = new Version(6);
|
||||
@@ -38,7 +38,7 @@ public class VersionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void sameVersionsEqualTwoDigits() {
|
||||
void sameVersionsEqualTwoDigits() {
|
||||
|
||||
Version first = new Version(5, 2);
|
||||
Version second = new Version(5, 2);
|
||||
@@ -48,7 +48,7 @@ public class VersionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void sameVersionsEqualThreeDigits() {
|
||||
void sameVersionsEqualThreeDigits() {
|
||||
|
||||
Version first = new Version(1, 2, 3);
|
||||
Version second = new Version(1, 2, 3);
|
||||
@@ -58,7 +58,7 @@ public class VersionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void sameVersionsEqualFourDigits() {
|
||||
void sameVersionsEqualFourDigits() {
|
||||
|
||||
Version first = new Version(1, 2, 3, 1000);
|
||||
Version second = new Version(1, 2, 3, 1000);
|
||||
@@ -68,35 +68,35 @@ public class VersionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void parsesVersionCorrectlyOneDigits() {
|
||||
void parsesVersionCorrectlyOneDigits() {
|
||||
|
||||
Version version = Version.parse("5");
|
||||
assertThat(version).isEqualTo(new Version(5));
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void parsesVersionCorrectlyTwoDigits() {
|
||||
void parsesVersionCorrectlyTwoDigits() {
|
||||
|
||||
Version version = Version.parse("5.2");
|
||||
assertThat(version).isEqualTo(new Version(5, 2));
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void parsesVersionCorrectlyThreeDigits() {
|
||||
void parsesVersionCorrectlyThreeDigits() {
|
||||
|
||||
Version version = Version.parse("12.1.3");
|
||||
assertThat(version).isEqualTo(new Version(12, 1, 3));
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void parsesVersionCorrectlyFourDigits() {
|
||||
void parsesVersionCorrectlyFourDigits() {
|
||||
|
||||
Version version = Version.parse("12.1.3.1000");
|
||||
assertThat(version).isEqualTo(new Version(12, 1, 3, 1000));
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void comparesToCorrectly() {
|
||||
void comparesToCorrectly() {
|
||||
|
||||
Version version = new Version(1, 2, 3, 1000);
|
||||
Version nextBuild = new Version(1, 2, 3, 1001);
|
||||
@@ -127,7 +127,7 @@ public class VersionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void removesTrailingZerosAfterSecondValueForToString() {
|
||||
void removesTrailingZerosAfterSecondValueForToString() {
|
||||
|
||||
assertThat(new Version(2)).hasToString("2.0");
|
||||
assertThat(new Version(2, 0)).hasToString("2.0");
|
||||
@@ -139,17 +139,17 @@ public class VersionUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-496
|
||||
public void parseShouldRemoveNonNumericVersionParts() {
|
||||
void parseShouldRemoveNonNumericVersionParts() {
|
||||
assertThat(Version.parse("2.0.0-rc1")).isEqualTo(new Version(2, 0, 0));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-719, DATACMNS-496
|
||||
public void removesNonNumericSuffix() {
|
||||
void removesNonNumericSuffix() {
|
||||
assertThat(Version.parse("4.2.0.RELEASE")).isEqualTo(new Version(4, 2, 0));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-719, DATACMNS-496
|
||||
public void rejectsNonNumericPartOnNonLastPosition() {
|
||||
void rejectsNonNumericPartOnNonLastPosition() {
|
||||
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Version.parse("1.RELEASE.2"))
|
||||
.withMessageContaining("1.RELEASE.2");
|
||||
|
||||
Reference in New Issue
Block a user