DATACMNS-867 - First draft.
This commit is contained in:
14
src/test/java/org/springframework/data/projection/DefaultProjectionInformationUnitTests.java
Normal file → Executable file
14
src/test/java/org/springframework/data/projection/DefaultProjectionInformationUnitTests.java
Normal file → Executable file
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -36,7 +36,7 @@ public class DefaultProjectionInformationUnitTests {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(CustomerProjection.class);
|
||||
|
||||
assertThat(toNames(information.getInputProperties()), contains("firstname", "lastname"));
|
||||
assertThat(toNames(information.getInputProperties())).contains("firstname", "lastname");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-89
|
||||
@@ -44,7 +44,7 @@ public class DefaultProjectionInformationUnitTests {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(ExtendedProjection.class);
|
||||
|
||||
assertThat(toNames(information.getInputProperties()), hasItems("age", "firstname", "lastname"));
|
||||
assertThat(toNames(information.getInputProperties())).containsExactly("age", "firstname", "lastname");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-967
|
||||
@@ -52,14 +52,14 @@ public class DefaultProjectionInformationUnitTests {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(WithDefaultMethod.class);
|
||||
|
||||
assertThat(information.isClosed(), is(true));
|
||||
assertThat(toNames(information.getInputProperties()), hasItems("firstname"));
|
||||
assertThat(information.isClosed()).isTrue();
|
||||
assertThat(toNames(information.getInputProperties())).contains("firstname");
|
||||
}
|
||||
|
||||
private static List<String> toNames(List<PropertyDescriptor> descriptors) {
|
||||
|
||||
return descriptors.stream()//
|
||||
.map(it -> it.getName())//
|
||||
.map(FeatureDescriptor::getName)//
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
13
src/test/java/org/springframework/data/projection/MapAccessingMethodInterceptorUnitTests.java
Normal file → Executable file
13
src/test/java/org/springframework/data/projection/MapAccessingMethodInterceptorUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -55,7 +54,7 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
MapAccessingMethodInterceptor interceptor = new MapAccessingMethodInterceptor(map);
|
||||
Object result = interceptor.invoke(invocation);
|
||||
|
||||
assertThat(result, is((Object) map.toString()));
|
||||
assertThat(result).isEqualTo(map.toString());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
@@ -68,8 +67,8 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
|
||||
Object result = new MapAccessingMethodInterceptor(map).invoke(invocation);
|
||||
|
||||
assertThat(result, is(nullValue()));
|
||||
assertThat(map.get("name"), is((Object) "Foo"));
|
||||
assertThat(result).isNull();
|
||||
assertThat(map.get("name")).isEqualTo("Foo");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
@@ -82,7 +81,7 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
|
||||
Object result = new MapAccessingMethodInterceptor(map).invoke(invocation);
|
||||
|
||||
assertThat(result, is((Object) "Foo"));
|
||||
assertThat(result).isEqualTo("Foo");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
@@ -92,7 +91,7 @@ public class MapAccessingMethodInterceptorUnitTests {
|
||||
|
||||
when(invocation.getMethod()).thenReturn(Sample.class.getMethod("getName"));
|
||||
|
||||
assertThat(new MapAccessingMethodInterceptor(map).invoke(invocation), is(nullValue()));
|
||||
assertThat(new MapAccessingMethodInterceptor(map).invoke(invocation)).isNull();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACMNS-630
|
||||
|
||||
61
src/test/java/org/springframework/data/projection/ProjectingMethodInterceptorUnitTests.java
Normal file → Executable file
61
src/test/java/org/springframework/data/projection/ProjectingMethodInterceptorUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@@ -24,13 +23,10 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -57,7 +53,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getHelper"));
|
||||
when(interceptor.invoke(invocation)).thenReturn("Foo");
|
||||
|
||||
assertThat(methodInterceptor.invoke(invocation), is(instanceOf(Helper.class)));
|
||||
assertThat(methodInterceptor.invoke(invocation)).isInstanceOf(Helper.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
@@ -68,7 +64,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getString"));
|
||||
when(interceptor.invoke(invocation)).thenReturn("Foo");
|
||||
|
||||
assertThat(methodInterceptor.invoke(invocation), is((Object) "Foo"));
|
||||
assertThat(methodInterceptor.invoke(invocation)).isEqualTo("Foo");
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
@@ -78,7 +74,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
|
||||
when(interceptor.invoke(invocation)).thenReturn(null);
|
||||
|
||||
assertThat(methodInterceptor.invoke(invocation), is(nullValue()));
|
||||
assertThat(methodInterceptor.invoke(invocation)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
@@ -89,7 +85,7 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
when(invocation.getMethod()).thenReturn(Helper.class.getMethod("getPrimitive"));
|
||||
when(interceptor.invoke(invocation)).thenReturn(1L);
|
||||
|
||||
assertThat(methodInterceptor.invoke(invocation), is((Object) 1L));
|
||||
assertThat(methodInterceptor.invoke(invocation)).isEqualTo(1L);
|
||||
verify(factory, times(0)).createProjection((Class<?>) anyObject(), anyObject());
|
||||
}
|
||||
|
||||
@@ -98,14 +94,14 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
public void appliesProjectionToNonEmptySets() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor);
|
||||
Object result = methodInterceptor.invoke(mockInvocationOf("getHelperCollection",
|
||||
Collections.singleton(mock(Helper.class))));
|
||||
Object result = methodInterceptor
|
||||
.invoke(mockInvocationOf("getHelperCollection", Collections.singleton(mock(Helper.class))));
|
||||
|
||||
assertThat(result, is(instanceOf(Set.class)));
|
||||
assertThat(result).isInstanceOf(Set.class);
|
||||
|
||||
Set<Object> projections = (Set<Object>) result;
|
||||
assertThat(projections, hasSize(1));
|
||||
assertThat(projections, hasItem(instanceOf(HelperProjection.class)));
|
||||
assertThat(projections).hasSize(1);
|
||||
assertThat(projections).hasOnlyElementsOfType(HelperProjection.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-394, DATAREST-408
|
||||
@@ -113,15 +109,15 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
public void appliesProjectionToNonEmptyLists() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor);
|
||||
Object result = methodInterceptor.invoke(mockInvocationOf("getHelperList",
|
||||
Collections.singletonList(mock(Helper.class))));
|
||||
Object result = methodInterceptor
|
||||
.invoke(mockInvocationOf("getHelperList", Collections.singletonList(mock(Helper.class))));
|
||||
|
||||
assertThat(result, is(instanceOf(List.class)));
|
||||
assertThat(result).isInstanceOf(List.class);
|
||||
|
||||
List<Object> projections = (List<Object>) result;
|
||||
|
||||
assertThat(projections, hasSize(1));
|
||||
assertThat(projections, hasItem(instanceOf(HelperProjection.class)));
|
||||
assertThat(projections).hasSize(1);
|
||||
assertThat(projections).hasOnlyElementsOfType(HelperProjection.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-394, DATAREST-408
|
||||
@@ -131,12 +127,12 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor);
|
||||
Object result = methodInterceptor.invoke(mockInvocationOf("getHelperArray", new Helper[] { mock(Helper.class) }));
|
||||
|
||||
assertThat(result, is(instanceOf(Collection.class)));
|
||||
assertThat(result).isInstanceOf(Collection.class);
|
||||
|
||||
Collection<Object> projections = (Collection<Object>) result;
|
||||
|
||||
assertThat(projections, hasSize(1));
|
||||
assertThat(projections, hasItem(instanceOf(HelperProjection.class)));
|
||||
assertThat(projections).hasSize(1);
|
||||
assertThat(projections).hasOnlyElementsOfType(HelperProjection.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-394, DATAREST-408
|
||||
@@ -145,18 +141,18 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor);
|
||||
|
||||
Object result = methodInterceptor.invoke(mockInvocationOf("getHelperMap",
|
||||
Collections.singletonMap("foo", mock(Helper.class))));
|
||||
Object result = methodInterceptor
|
||||
.invoke(mockInvocationOf("getHelperMap", Collections.singletonMap("foo", mock(Helper.class))));
|
||||
|
||||
assertThat(result, is(instanceOf(Map.class)));
|
||||
assertThat(result).isInstanceOf(Map.class);
|
||||
|
||||
Map<String, Object> projections = (Map<String, Object>) result;
|
||||
assertThat(projections.entrySet(), is(Matchers.<Entry<String, Object>> iterableWithSize(1)));
|
||||
assertThat(projections, hasEntry(is("foo"), instanceOf(HelperProjection.class)));
|
||||
|
||||
assertThat(projections).hasSize(1);
|
||||
assertThat(projections).matches(map -> map.get("foo") instanceof HelperProjection);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void returnsSingleElementCollectionForTargetThatReturnsNonCollection() throws Throwable {
|
||||
|
||||
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(new ProxyProjectionFactory(), interceptor);
|
||||
@@ -164,9 +160,12 @@ public class ProjectingMethodInterceptorUnitTests {
|
||||
Helper reference = mock(Helper.class);
|
||||
Object result = methodInterceptor.invoke(mockInvocationOf("getHelperCollection", reference));
|
||||
|
||||
assertThat(result, is((Matcher<Object>) instanceOf(Collection.class)));
|
||||
assertThat((Collection<?>) result, hasSize(1));
|
||||
assertThat((Collection<Object>) result, hasItem(instanceOf(HelperProjection.class)));
|
||||
assertThat(result).isInstanceOf(Collection.class);
|
||||
|
||||
Collection<?> collection = (Collection<?>) result;
|
||||
|
||||
assertThat(collection).hasSize(1);
|
||||
assertThat(collection).hasOnlyElementsOfType(HelperProjection.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
7
src/test/java/org/springframework/data/projection/PropertyAccessingMethodInterceptorUnitTests.java
Normal file → Executable file
7
src/test/java/org/springframework/data/projection/PropertyAccessingMethodInterceptorUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
@@ -48,7 +47,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("getFirstname"));
|
||||
MethodInterceptor interceptor = new PropertyAccessingMethodInterceptor(source);
|
||||
|
||||
assertThat(interceptor.invoke(invocation), is((Object) "Dave"));
|
||||
assertThat(interceptor.invoke(invocation)).isEqualTo("Dave");
|
||||
}
|
||||
|
||||
@Test(expected = NotReadablePropertyException.class) // DATAREST-221
|
||||
@@ -85,7 +84,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
|
||||
|
||||
new PropertyAccessingMethodInterceptor(source).invoke(invocation);
|
||||
|
||||
assertThat(source.firstname, is((Object) "Carl"));
|
||||
assertThat(source.firstname).isEqualTo("Carl");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class) // DATACMNS-820
|
||||
|
||||
49
src/test/java/org/springframework/data/projection/ProxyProjectionFactoryUnitTests.java
Normal file → Executable file
49
src/test/java/org/springframework/data/projection/ProxyProjectionFactoryUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Proxy;
|
||||
@@ -57,7 +56,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
@Test // DATACMNS-630
|
||||
public void returnsNullForNullSource() {
|
||||
assertThat(factory.createProjection(CustomerExcerpt.class, null), is(nullValue()));
|
||||
assertThat(factory.createProjection(CustomerExcerpt.class, null)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
@@ -73,8 +72,8 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class, customer);
|
||||
|
||||
assertThat(excerpt.getFirstname(), is("Dave"));
|
||||
assertThat(excerpt.getAddress().getZipCode(), is("ZIP"));
|
||||
assertThat(excerpt.getFirstname()).isEqualTo("Dave");
|
||||
assertThat(excerpt.getAddress().getZipCode()).isEqualTo("ZIP");
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
@@ -83,8 +82,8 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerExcerpt proxy = factory.createProjection(CustomerExcerpt.class);
|
||||
|
||||
assertThat(proxy, is(instanceOf(TargetClassAware.class)));
|
||||
assertThat(((TargetClassAware) proxy).getTargetClass(), is(equalTo((Class) HashMap.class)));
|
||||
assertThat(proxy).isInstanceOf(TargetClassAware.class);
|
||||
assertThat(((TargetClassAware) proxy).getTargetClass()).isEqualTo(HashMap.class);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-221, DATACMNS-630
|
||||
@@ -106,11 +105,11 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerExcerpt projection = factory.createProjection(CustomerExcerpt.class, source);
|
||||
|
||||
assertThat(projection.getFirstname(), is("Dave"));
|
||||
assertThat(projection.getFirstname()).isEqualTo("Dave");
|
||||
|
||||
AddressExcerpt address = projection.getAddress();
|
||||
assertThat(address, is(notNullValue()));
|
||||
assertThat(address.getZipCode(), is("ZIP"));
|
||||
assertThat(address).isNotNull();
|
||||
assertThat(address.getZipCode()).isEqualTo("ZIP");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
@@ -118,10 +117,10 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerProxy proxy = factory.createProjection(CustomerProxy.class);
|
||||
|
||||
assertThat(proxy, is(notNullValue()));
|
||||
assertThat(proxy).isNotNull();
|
||||
|
||||
proxy.setFirstname("Dave");
|
||||
assertThat(proxy.getFirstname(), is("Dave"));
|
||||
assertThat(proxy.getFirstname()).isEqualTo("Dave");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
@@ -130,7 +129,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
ProjectionInformation projectionInformation = factory.getProjectionInformation(CustomerExcerpt.class);
|
||||
List<PropertyDescriptor> result = projectionInformation.getInputProperties();
|
||||
|
||||
assertThat(result, hasSize(6));
|
||||
assertThat(result).hasSize(6);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-655
|
||||
@@ -141,8 +140,8 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
Advised advised = (Advised) ReflectionTestUtils.getField(Proxy.getInvocationHandler(excerpt), "advised");
|
||||
Advisor[] advisors = advised.getAdvisors();
|
||||
|
||||
assertThat(advisors.length, is(greaterThan(0)));
|
||||
assertThat(advisors[0].getAdvice(), is(instanceOf(DefaultMethodInvokingMethodInterceptor.class)));
|
||||
assertThat(advisors.length).isGreaterThan(0);
|
||||
assertThat(advisors[0].getAdvice()).isInstanceOf(DefaultMethodInvokingMethodInterceptor.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-648
|
||||
@@ -150,8 +149,8 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class);
|
||||
|
||||
assertThat(excerpt, is(instanceOf(TargetAware.class)));
|
||||
assertThat(((TargetAware) excerpt).getTarget(), is(instanceOf(Map.class)));
|
||||
assertThat(excerpt).isInstanceOf(TargetAware.class);
|
||||
assertThat(((TargetAware) excerpt).getTarget()).isInstanceOf(Map.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-722
|
||||
@@ -162,7 +161,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class, customer);
|
||||
|
||||
assertThat(excerpt.getPicture(), is(customer.picture));
|
||||
assertThat(excerpt.getPicture()).isEqualTo(customer.picture);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-722
|
||||
@@ -177,7 +176,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class, customer);
|
||||
|
||||
assertThat(excerpt.getShippingAddresses(), is(arrayWithSize(1)));
|
||||
assertThat(excerpt.getShippingAddresses()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-782
|
||||
@@ -188,7 +187,7 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class, customer);
|
||||
|
||||
assertThat(excerpt.getId(), is(customer.id.toString()));
|
||||
assertThat(excerpt.getId()).isEqualTo(customer.id.toString());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-89
|
||||
@@ -196,8 +195,8 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
ProjectionInformation information = factory.getProjectionInformation(CustomerExcerpt.class);
|
||||
|
||||
assertThat(information.getType(), is(typeCompatibleWith(CustomerExcerpt.class)));
|
||||
assertThat(information.isClosed(), is(true));
|
||||
assertThat(information.getType()).isEqualTo(CustomerExcerpt.class);
|
||||
assertThat(information.isClosed()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-829
|
||||
@@ -208,9 +207,9 @@ public class ProxyProjectionFactoryUnitTests {
|
||||
|
||||
Map<String, Object> data = factory.createProjection(CustomerExcerpt.class, customer).getData();
|
||||
|
||||
assertThat(data, is(notNullValue()));
|
||||
assertThat(data.containsKey("key"), is(true));
|
||||
assertThat(data.get("key"), is(nullValue()));
|
||||
assertThat(data).isNotNull();
|
||||
assertThat(data.containsKey("key")).isTrue();
|
||||
assertThat(data.get("key")).isNull();
|
||||
}
|
||||
|
||||
static class Customer {
|
||||
|
||||
12
src/test/java/org/springframework/data/projection/SpelAwareProxyProjectionFactoryUnitTests.java
Normal file → Executable file
12
src/test/java/org/springframework/data/projection/SpelAwareProxyProjectionFactoryUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
customer.lastname = "Matthews";
|
||||
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class, customer);
|
||||
assertThat(excerpt.getFullName(), is("Dave Matthews"));
|
||||
assertThat(excerpt.getFullName()).isEqualTo("Dave Matthews");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
@@ -61,8 +60,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
|
||||
List<String> properties = factory.getInputProperties(CustomerExcerpt.class);
|
||||
|
||||
assertThat(properties, hasSize(1));
|
||||
assertThat(properties, hasItem("firstname"));
|
||||
assertThat(properties).containsExactly("firstname");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-89
|
||||
@@ -70,7 +68,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
|
||||
ProjectionInformation information = factory.getProjectionInformation(CustomerExcerpt.class);
|
||||
|
||||
assertThat(information.isClosed(), is(false));
|
||||
assertThat(information.isClosed()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-820
|
||||
@@ -82,7 +80,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
|
||||
CustomerExcerpt excerpt = factory.createProjection(CustomerExcerpt.class, customer);
|
||||
excerpt.setFirstname("Carl");
|
||||
|
||||
assertThat(customer.firstname, is("Carl"));
|
||||
assertThat(customer.firstname).isEqualTo("Carl");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-820
|
||||
|
||||
9
src/test/java/org/springframework/data/projection/SpelEvaluatingMethodInterceptorUnitTests.java
Normal file → Executable file
9
src/test/java/org/springframework/data/projection/SpelEvaluatingMethodInterceptorUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.projection;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -54,7 +53,7 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
MethodInterceptor interceptor = new SpelEvaluatingMethodInterceptor(delegate, new Target(), null, parser,
|
||||
Projection.class);
|
||||
|
||||
assertThat(interceptor.invoke(invocation), is((Object) "property"));
|
||||
assertThat(interceptor.invoke(invocation)).isEqualTo("property");
|
||||
}
|
||||
|
||||
@Test // DATAREST-221, DATACMNS-630
|
||||
@@ -68,7 +67,7 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
SpelEvaluatingMethodInterceptor interceptor = new SpelEvaluatingMethodInterceptor(delegate, new Target(), factory,
|
||||
parser, Projection.class);
|
||||
|
||||
assertThat(interceptor.invoke(invocation), is((Object) "value"));
|
||||
assertThat(interceptor.invoke(invocation)).isEqualTo("value");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-630
|
||||
@@ -106,7 +105,7 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
|
||||
SpelEvaluatingMethodInterceptor interceptor = new SpelEvaluatingMethodInterceptor(delegate, map,
|
||||
new DefaultListableBeanFactory(), parser, Projection.class);
|
||||
|
||||
assertThat(interceptor.invoke(invocation), is((Object) "Dave"));
|
||||
assertThat(interceptor.invoke(invocation)).isEqualTo("Dave");
|
||||
}
|
||||
|
||||
interface Projection {
|
||||
|
||||
Reference in New Issue
Block a user