DATACMNS-867 - Post-rebase changes.
Adopt tests to AssertJ. Remove superflous Mockito stubbing.
This commit is contained in:
committed by
Oliver Gierke
parent
250b1cf613
commit
6e0596694d
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.assumeThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -25,6 +26,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -56,6 +58,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
|
||||
@@ -175,12 +178,12 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
|
||||
assumeThat(System.getProperty("java.version"), CoreMatchers.startsWith("1.6"));
|
||||
|
||||
SampleMappingContext context = new SampleMappingContext();
|
||||
PersistentEntity<Object, SamplePersistentProperty> entity = context.getPersistentEntity(Entity.class);
|
||||
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
|
||||
|
||||
Entity value = new Entity();
|
||||
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(value);
|
||||
|
||||
assertThat(accessor).isEqualTo(instanceOf(BeanWrapper.class));
|
||||
assertThat(accessor).isInstanceOf(BeanWrapper.class);
|
||||
assertThat(accessor.getBean()).isEqualTo(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.data.repository.core.support.EventPublishingRepositor
|
||||
* Unit tests for {@link EventPublishingRepositoryProxyPostProcessor} and contained classes.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @soundtrack Henrik Freischlader Trio - Nobody Else To Blame (Openness)
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -175,9 +176,6 @@ public class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
@Test // DATACMNS-975
|
||||
public void publishesEventsAfterSaveInvocation() throws Throwable {
|
||||
|
||||
doReturn(SampleRepository.class.getMethod("save", Object.class)).when(invocation).getMethod();
|
||||
doReturn(new Object[] { OneEvent.of(new SomeEvent()) }).when(invocation).getArguments();
|
||||
|
||||
doThrow(new IllegalStateException()).when(invocation).proceed();
|
||||
|
||||
try {
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat
|
||||
* Unit tests for {@link ReturnedType}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class ReturnedTypeUnitTests {
|
||||
|
||||
@@ -152,8 +153,7 @@ public class ReturnedTypeUnitTests {
|
||||
|
||||
List<String> properties = type.getInputProperties();
|
||||
|
||||
assertThat(properties, hasSize(1));
|
||||
assertThat(properties, contains("firstname"));
|
||||
assertThat(properties).hasSize(1).contains("firstname");
|
||||
}
|
||||
|
||||
private static ReturnedType getReturnedType(String methodName, Class<?>... parameters) throws Exception {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.http.MediaType;
|
||||
* Unit tests for {@link ProjectingJackson2HttpMessageConverter}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @soundtrack Richard Spaven - Tribute (Whole Other*)
|
||||
* @since 1.13
|
||||
*/
|
||||
@@ -56,7 +57,7 @@ public class ProjectingJackson2HttpMessageConverterUnitTests {
|
||||
Method method = BaseController.class.getDeclaredMethod("createEntity", AbstractDto.class);
|
||||
Type type = method.getGenericParameterTypes()[0];
|
||||
|
||||
assertThat(converter.canRead(type, BaseController.class, ANYTHING_JSON), is(false));
|
||||
assertThat(converter.canRead(type, BaseController.class, ANYTHING_JSON)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-972
|
||||
@@ -65,7 +66,7 @@ public class ProjectingJackson2HttpMessageConverterUnitTests {
|
||||
Method method = ConcreteController.class.getMethod("createEntity", AbstractDto.class);
|
||||
Type type = method.getGenericParameterTypes()[0];
|
||||
|
||||
assertThat(converter.canRead(type, ConcreteController.class, ANYTHING_JSON), is(false));
|
||||
assertThat(converter.canRead(type, ConcreteController.class, ANYTHING_JSON)).isFalse();
|
||||
}
|
||||
|
||||
@ProjectedPayload
|
||||
|
||||
Reference in New Issue
Block a user