DATACMNS-1718 - Migrate tests to JUnit 5.
This commit is contained in:
@@ -16,9 +16,9 @@
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.MethodHandleLookup;
|
||||
import org.springframework.data.util.Version;
|
||||
|
||||
@@ -28,21 +28,21 @@ import org.springframework.data.util.Version;
|
||||
* @author Mark Paluch
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class DefaultMethodInvokingMethodInterceptorUnitTests {
|
||||
class DefaultMethodInvokingMethodInterceptorUnitTests {
|
||||
|
||||
@Test // DATACMNS-1376
|
||||
public void shouldApplyEncapsulatedLookupOnJava9AndHigher() {
|
||||
void shouldApplyEncapsulatedLookupOnJava9AndHigher() {
|
||||
|
||||
assumeTrue(Version.javaVersion().isGreaterThanOrEqualTo(Version.parse("9.0")));
|
||||
assumeThat(Version.javaVersion()).isGreaterThanOrEqualTo(Version.parse("9.0"));
|
||||
|
||||
assertThat(MethodHandleLookup.getMethodHandleLookup()).isEqualTo(MethodHandleLookup.ENCAPSULATED);
|
||||
assertThat(MethodHandleLookup.ENCAPSULATED.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1376
|
||||
public void shouldApplyOpenLookupOnJava8() {
|
||||
void shouldApplyOpenLookupOnJava8() {
|
||||
|
||||
assumeTrue(Version.javaVersion().isLessThan(Version.parse("1.8.9999")));
|
||||
assumeThat(Version.javaVersion()).isLessThan(Version.parse("1.8.9999"));
|
||||
|
||||
assertThat(MethodHandleLookup.getMethodHandleLookup()).isEqualTo(MethodHandleLookup.OPEN);
|
||||
assertThat(MethodHandleLookup.OPEN.isAvailable()).isTrue();
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.beans.PropertyDescriptor;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
@@ -31,10 +31,10 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class DefaultProjectionInformationUnitTests {
|
||||
class DefaultProjectionInformationUnitTests {
|
||||
|
||||
@Test // DATACMNS-89
|
||||
public void discoversInputProperties() {
|
||||
void discoversInputProperties() {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(CustomerProjection.class);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DefaultProjectionInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1206
|
||||
public void omitsInputPropertiesAcceptingArguments() {
|
||||
void omitsInputPropertiesAcceptingArguments() {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(ProjectionAcceptingArguments.class);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class DefaultProjectionInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-89
|
||||
public void discoversAllInputProperties() {
|
||||
void discoversAllInputProperties() {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(ExtendedProjection.class);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DefaultProjectionInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1206
|
||||
public void discoversInputPropertiesInOrder() {
|
||||
void discoversInputPropertiesInOrder() {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(SameMethodNamesInAlternateOrder.class);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DefaultProjectionInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1206
|
||||
public void discoversAllInputPropertiesInOrder() {
|
||||
void discoversAllInputPropertiesInOrder() {
|
||||
|
||||
assertThat(toNames(new DefaultProjectionInformation(CompositeProjection.class).getInputProperties()))
|
||||
.containsExactly("firstname", "lastname", "age");
|
||||
@@ -75,7 +75,7 @@ public class DefaultProjectionInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-967
|
||||
public void doesNotConsiderDefaultMethodInputProperties() {
|
||||
void doesNotConsiderDefaultMethodInputProperties() {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(WithDefaultMethod.class);
|
||||
|
||||
|
||||
@@ -23,28 +23,28 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
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 MapAccessingMethodInterceptor}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MapAccessingMethodInterceptorUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MapAccessingMethodInterceptorUnitTests {
|
||||
|
||||
@Mock MethodInvocation invocation;
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void rejectsNullMap() {
|
||||
void rejectsNullMap() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new MapAccessingMethodInterceptor(null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void forwardsObjectMethodsToBackingMap() throws Throwable {
|
||||
void forwardsObjectMethodsToBackingMap() throws Throwable {
|
||||
|
||||
Map<String, Object> map = Collections.emptyMap();
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void setterInvocationStoresValueInMap() throws Throwable {
|
||||
void setterInvocationStoresValueInMap() throws Throwable {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void getterInvocationReturnsValueFromMap() throws Throwable {
|
||||
void getterInvocationReturnsValueFromMap() throws Throwable {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", "Foo");
|
||||
@@ -85,7 +85,7 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void getterReturnsNullIfMapDoesNotContainValue() throws Throwable {
|
||||
void getterReturnsNullIfMapDoesNotContainValue() throws Throwable {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
@@ -95,7 +95,7 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void rejectsNonAccessorInvocation() throws Throwable {
|
||||
void rejectsNonAccessorInvocation() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Sample.class.getMethod("someMethod"));
|
||||
assertThatIllegalArgumentException()
|
||||
|
||||
@@ -28,10 +28,11 @@ import java.util.Set;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
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.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
|
||||
@@ -42,8 +43,8 @@ import org.springframework.core.convert.support.DefaultConversionService;
|
||||
* @author Saulo Medeiros de Araujo
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ProjectingMethodInterceptorUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class ProjectingMethodInterceptorUnitTests {
|
||||
|
||||
@Mock MethodInterceptor interceptor;
|
||||
@Mock MethodInvocation invocation;
|
||||
@@ -51,7 +52,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
ConversionService conversionService = new DefaultConversionService();
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void wrapsDelegateResultInProxyIfTypesDontMatch() throws Throwable {
|
||||
void wrapsDelegateResultInProxyIfTypesDontMatch() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor,
|
||||
conversionService);
|
||||
@@ -63,7 +64,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void retunsDelegateResultAsIsIfTypesMatch() throws Throwable {
|
||||
void retunsDelegateResultAsIsIfTypesMatch() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor, conversionService);
|
||||
|
||||
@@ -74,7 +75,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void returnsNullAsIs() throws Throwable {
|
||||
void returnsNullAsIs() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor, conversionService);
|
||||
|
||||
@@ -84,7 +85,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void considersPrimitivesAsWrappers() throws Throwable {
|
||||
void considersPrimitivesAsWrappers() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor, conversionService);
|
||||
|
||||
@@ -97,7 +98,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
|
||||
@Test // DATAREST-394, DATAREST-408
|
||||
@SuppressWarnings("unchecked")
|
||||
public void appliesProjectionToNonEmptySets() throws Throwable {
|
||||
void appliesProjectionToNonEmptySets() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor,
|
||||
conversionService);
|
||||
@@ -112,7 +113,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
|
||||
@Test // DATAREST-394, DATAREST-408
|
||||
@SuppressWarnings("unchecked")
|
||||
public void appliesProjectionToNonEmptyLists() throws Throwable {
|
||||
void appliesProjectionToNonEmptyLists() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor,
|
||||
conversionService);
|
||||
@@ -128,7 +129,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
|
||||
@Test // DATAREST-394, DATAREST-408
|
||||
@SuppressWarnings("unchecked")
|
||||
public void allowsMaskingAnArrayIntoACollection() throws Throwable {
|
||||
void allowsMaskingAnArrayIntoACollection() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor,
|
||||
conversionService);
|
||||
@@ -143,7 +144,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
|
||||
@Test // DATAREST-394, DATAREST-408
|
||||
@SuppressWarnings("unchecked")
|
||||
public void appliesProjectionToNonEmptyMap() throws Throwable {
|
||||
void appliesProjectionToNonEmptyMap() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor,
|
||||
conversionService);
|
||||
@@ -159,7 +160,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsSingleElementCollectionForTargetThatReturnsNonCollection() throws Throwable {
|
||||
void returnsSingleElementCollectionForTargetThatReturnsNonCollection() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor,
|
||||
conversionService);
|
||||
@@ -175,7 +176,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1598
|
||||
public void returnsEnumSet() throws Throwable {
|
||||
void returnsEnumSet() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor,
|
||||
conversionService);
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.projection;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.jsonpath.Configuration.ConfigurationBuilder;
|
||||
@@ -31,10 +31,10 @@ import com.jayway.jsonpath.ParseContext;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class ProjectionIntegrationTests {
|
||||
class ProjectionIntegrationTests {
|
||||
|
||||
@Test // DATACMNS-909
|
||||
public void jacksonSerializationDoesNotExposeDecoratedClass() throws Exception {
|
||||
void jacksonSerializationDoesNotExposeDecoratedClass() throws Exception {
|
||||
|
||||
ProxyProjectionFactory factory = new ProxyProjectionFactory();
|
||||
SampleProjection projection = factory.createProjection(SampleProjection.class);
|
||||
|
||||
@@ -20,10 +20,11 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
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.beans.NotReadablePropertyException;
|
||||
import org.springframework.beans.NotWritablePropertyException;
|
||||
|
||||
@@ -33,13 +34,13 @@ import org.springframework.beans.NotWritablePropertyException;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class PropertyAccessingMethodInterceptorUnitTests {
|
||||
|
||||
@Mock MethodInvocation invocation;
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void triggersPropertyAccessOnTarget() throws Throwable {
|
||||
void triggersPropertyAccessOnTarget() throws Throwable {
|
||||
|
||||
Source source = new Source();
|
||||
source.firstname = "Dave";
|
||||
@@ -51,7 +52,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void throwsAppropriateExceptionIfThePropertyCannotBeFound() throws Throwable {
|
||||
void throwsAppropriateExceptionIfThePropertyCannotBeFound() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("getLastname"));
|
||||
assertThatExceptionOfType(NotReadablePropertyException.class)
|
||||
@@ -59,7 +60,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void forwardsObjectMethodInvocation() throws Throwable {
|
||||
void forwardsObjectMethodInvocation() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Object.class.getMethod("toString"));
|
||||
|
||||
@@ -67,7 +68,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void rejectsNonAccessorMethod() throws Throwable {
|
||||
void rejectsNonAccessorMethod() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("someGarbage"));
|
||||
|
||||
@@ -76,7 +77,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-820
|
||||
public void triggersWritePropertyAccessOnTarget() throws Throwable {
|
||||
void triggersWritePropertyAccessOnTarget() throws Throwable {
|
||||
|
||||
Source source = new Source();
|
||||
source.firstname = "Dave";
|
||||
@@ -90,7 +91,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-820
|
||||
public void throwsAppropriateExceptionIfTheInvocationHasNoArguments() throws Throwable {
|
||||
void throwsAppropriateExceptionIfTheInvocationHasNoArguments() throws Throwable {
|
||||
|
||||
Source source = new Source();
|
||||
|
||||
@@ -102,7 +103,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-820
|
||||
public void throwsAppropriateExceptionIfThePropertyCannotWritten() throws Throwable {
|
||||
void throwsAppropriateExceptionIfThePropertyCannotWritten() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("setGarbage", String.class));
|
||||
when(invocation.getArguments()).thenReturn(new Object[] { "Carl" });
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.TargetClassAware;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
@@ -35,31 +35,31 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class ProxyProjectionFactoryUnitTests {
|
||||
class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
ProjectionFactory factory = new ProxyProjectionFactory();
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("null")
|
||||
// DATACMNS-630
|
||||
public void rejectsNullProjectionType() {
|
||||
void rejectsNullProjectionType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factory.createProjection(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("null")
|
||||
// DATACMNS-630
|
||||
public void rejectsNullProjectionTypeWithSource() {
|
||||
void rejectsNullProjectionTypeWithSource() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factory.createProjection(null, new Object()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void returnsNullForNullSource() {
|
||||
void returnsNullForNullSource() {
|
||||
assertThat(factory.createNullableProjection(CustomerExcerpt.class, null)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
public void createsProjectingProxy() {
|
||||
void createsProjectingProxy() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.firstname = "Dave";
|
||||
@@ -76,7 +76,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
public void proxyExposesTargetClassAware() {
|
||||
void proxyExposesTargetClassAware() {
|
||||
|
||||
CustomerExcerpt proxy = factory.createProjection(CustomerExcerpt.class);
|
||||
|
||||
@@ -85,12 +85,12 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
public void rejectsNonInterfacesAsProjectionTarget() {
|
||||
void rejectsNonInterfacesAsProjectionTarget() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factory.createProjection(Object.class, new Object()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void createsMapBasedProxyFromSource() {
|
||||
void createsMapBasedProxyFromSource() {
|
||||
|
||||
HashMap<String, Object> addressSource = new HashMap<>();
|
||||
addressSource.put("zipCode", "ZIP");
|
||||
@@ -111,7 +111,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void createsEmptyMapBasedProxy() {
|
||||
void createsEmptyMapBasedProxy() {
|
||||
|
||||
CustomerProxy proxy = factory.createProjection(CustomerProxy.class);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void returnsAllPropertiesAsInputProperties() {
|
||||
void returnsAllPropertiesAsInputProperties() {
|
||||
|
||||
ProjectionInformation projectionInformation = factory.getProjectionInformation(CustomerExcerpt.class);
|
||||
List<PropertyDescriptor> result = projectionInformation.getInputProperties();
|
||||
@@ -131,7 +131,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-655
|
||||
public void invokesDefaultMethodOnProxy() {
|
||||
void invokesDefaultMethodOnProxy() {
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class);
|
||||
|
||||
@@ -143,7 +143,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-648
|
||||
public void exposesProxyTarget() {
|
||||
void exposesProxyTarget() {
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class);
|
||||
|
||||
@@ -152,7 +152,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-722
|
||||
public void doesNotProjectPrimitiveArray() {
|
||||
void doesNotProjectPrimitiveArray() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.picture = "binarydata".getBytes();
|
||||
@@ -163,7 +163,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-722
|
||||
public void projectsNonPrimitiveArray() {
|
||||
void projectsNonPrimitiveArray() {
|
||||
|
||||
Address address = new Address();
|
||||
address.city = "New York";
|
||||
@@ -178,7 +178,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-782
|
||||
public void convertsPrimitiveValues() {
|
||||
void convertsPrimitiveValues() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.id = 1L;
|
||||
@@ -189,7 +189,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-89
|
||||
public void exposesProjectionInformationCorrectly() {
|
||||
void exposesProjectionInformationCorrectly() {
|
||||
|
||||
ProjectionInformation information = factory.getProjectionInformation(CustomerExcerpt.class);
|
||||
|
||||
@@ -198,7 +198,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-829
|
||||
public void projectsMapOfStringToObjectCorrectly() {
|
||||
void projectsMapOfStringToObjectCorrectly() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.data = Collections.singletonMap("key", null);
|
||||
@@ -211,7 +211,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1121
|
||||
public void doesNotCreateWrappingProxyIfTargetImplementsProjectionInterface() {
|
||||
void doesNotCreateWrappingProxyIfTargetImplementsProjectionInterface() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
|
||||
@@ -222,17 +222,17 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
static class Customer implements Contact {
|
||||
|
||||
public Long id;
|
||||
public String firstname, lastname;
|
||||
public Address address;
|
||||
public byte[] picture;
|
||||
public Address[] shippingAddresses;
|
||||
public Map<String, Object> data;
|
||||
Long id;
|
||||
String firstname, lastname;
|
||||
Address address;
|
||||
byte[] picture;
|
||||
Address[] shippingAddresses;
|
||||
Map<String, Object> data;
|
||||
}
|
||||
|
||||
static class Address {
|
||||
|
||||
public String zipCode, city;
|
||||
String zipCode, city;
|
||||
}
|
||||
|
||||
interface CustomerExcerpt {
|
||||
|
||||
@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import java.beans.PropertyDescriptor;
|
||||
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.beans.NotWritablePropertyException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -33,17 +33,17 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
|
||||
SpelAwareProxyProjectionFactory factory;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
factory = new SpelAwareProxyProjectionFactory();
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
public void exposesSpelInvokingMethod() {
|
||||
void exposesSpelInvokingMethod() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.firstname = "Dave";
|
||||
@@ -54,7 +54,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void excludesAtValueAnnotatedMethodsForInputProperties() {
|
||||
void excludesAtValueAnnotatedMethodsForInputProperties() {
|
||||
|
||||
List<PropertyDescriptor> properties = factory //
|
||||
.getProjectionInformation(CustomerExcerpt.class) //
|
||||
@@ -66,7 +66,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-89
|
||||
public void considersProjectionUsingAtValueNotClosed() {
|
||||
void considersProjectionUsingAtValueNotClosed() {
|
||||
|
||||
ProjectionInformation information = factory.getProjectionInformation(CustomerExcerpt.class);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-820
|
||||
public void setsValueUsingProjection() {
|
||||
void setsValueUsingProjection() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.firstname = "Dave";
|
||||
@@ -86,7 +86,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-820
|
||||
public void settingNotWriteablePropertyFails() {
|
||||
void settingNotWriteablePropertyFails() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.firstname = "Dave";
|
||||
|
||||
@@ -23,10 +23,11 @@ import java.util.Map;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
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.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
@@ -37,8 +38,8 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
|
||||
@Mock MethodInterceptor delegate;
|
||||
@Mock MethodInvocation invocation;
|
||||
@@ -46,7 +47,7 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
public void invokesMethodOnTarget() throws Throwable {
|
||||
void invokesMethodOnTarget() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("propertyFromTarget"));
|
||||
|
||||
@@ -57,7 +58,7 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
public void invokesMethodOnBean() throws Throwable {
|
||||
void invokesMethodOnBean() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("invokeBean"));
|
||||
|
||||
@@ -71,7 +72,7 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void forwardNonAtValueAnnotatedMethodToDelegate() throws Throwable {
|
||||
void forwardNonAtValueAnnotatedMethodToDelegate() throws Throwable {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("getName"));
|
||||
|
||||
@@ -84,13 +85,13 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void rejectsEmptySpelExpression() {
|
||||
void rejectsEmptySpelExpression() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> new SpelEvaluatingMethodInterceptor(delegate, new Target(),
|
||||
new DefaultListableBeanFactory(), parser, InvalidProjection.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void allowsMapAccessViaPropertyExpression() throws Throwable {
|
||||
void allowsMapAccessViaPropertyExpression() throws Throwable {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", "Dave");
|
||||
@@ -104,7 +105,7 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1150
|
||||
public void forwardsParameterIntoSpElExpressionEvaluation() throws Throwable {
|
||||
void forwardsParameterIntoSpElExpressionEvaluation() throws Throwable {
|
||||
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
factory.registerSingleton("someBean", new SomeBean());
|
||||
|
||||
Reference in New Issue
Block a user