DATACMNS-867 - Additional Java 8 language feature cleanup.
Make use of lambdas and method references though out the codebase. Remove no longer required generic type parameters. Additionally remove unused imports and replace single element list initialization with dedicated singletonList. Use Assertion overloads taking Supplier for dynamic assertion error messages.
This commit is contained in:
committed by
Oliver Gierke
parent
aa4c51e1ea
commit
be347eaaab
@@ -44,17 +44,13 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
@Test
|
||||
public void returnsAuditableInterfaceBeanWrapperForAuditable() {
|
||||
|
||||
assertThat(factory.getBeanWrapperFor(Optional.of(new AuditedUser()))).hasValueSatisfying(it -> {
|
||||
assertThat(it).isInstanceOf(AuditableInterfaceBeanWrapper.class);
|
||||
});
|
||||
assertThat(factory.getBeanWrapperFor(Optional.of(new AuditedUser()))).hasValueSatisfying(it -> assertThat(it).isInstanceOf(AuditableInterfaceBeanWrapper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsReflectionAuditingBeanWrapperForNonAuditableButAnnotated() {
|
||||
|
||||
assertThat(factory.getBeanWrapperFor(Optional.of(new AnnotatedUser()))).hasValueSatisfying(it -> {
|
||||
assertThat(it).isInstanceOf(ReflectionAuditingBeanWrapper.class);
|
||||
});
|
||||
assertThat(factory.getBeanWrapperFor(Optional.of(new AnnotatedUser()))).hasValueSatisfying(it -> assertThat(it).isInstanceOf(ReflectionAuditingBeanWrapper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,8 +85,6 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
|
||||
Optional<AuditableBeanWrapper> wrapper = factory.getBeanWrapperFor(Optional.of(user));
|
||||
|
||||
assertThat(wrapper).hasValueSatisfying(it -> {
|
||||
it.setLastModifiedDate(Optional.of(zonedDateTime));
|
||||
});
|
||||
assertThat(wrapper).hasValueSatisfying(it -> it.setLastModifiedDate(Optional.of(zonedDateTime)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void setsUpHandlerWithMappingContext() {
|
||||
new IsNewAwareAuditingHandler(new PersistentEntities(Collections.<MappingContext<?, ?>> emptySet()));
|
||||
new IsNewAwareAuditingHandler(new PersistentEntities(Collections.emptySet()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638
|
||||
|
||||
@@ -96,9 +96,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
|
||||
Optional<AuditableBeanWrapper> wrapper = factory.getBeanWrapperFor(Optional.of(sample));
|
||||
|
||||
assertThat(wrapper).hasValueSatisfying(it -> {
|
||||
it.setLastModifiedDate(Optional.of(Instant.now()));
|
||||
});
|
||||
assertThat(wrapper).hasValueSatisfying(it -> it.setLastModifiedDate(Optional.of(Instant.now())));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
@@ -109,9 +107,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
@Test // DATACMNS-365
|
||||
public void returnsAuditableWrapperForAuditable() {
|
||||
|
||||
assertThat(factory.getBeanWrapperFor(Optional.of(mock(ExtendingAuditable.class)))).hasValueSatisfying(it -> {
|
||||
assertThat(it).isInstanceOf(AuditableInterfaceBeanWrapper.class);
|
||||
});
|
||||
assertThat(factory.getBeanWrapperFor(Optional.of(mock(ExtendingAuditable.class)))).hasValueSatisfying(it -> assertThat(it).isInstanceOf(AuditableInterfaceBeanWrapper.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638
|
||||
@@ -166,9 +162,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
|
||||
Optional<AuditableBeanWrapper> wrapper = factory.getBeanWrapperFor(Optional.of(sample));
|
||||
|
||||
assertThat(wrapper).hasValueSatisfying(it -> {
|
||||
assertThat(it.getLastModifiedDate()).isEqualTo(expected);
|
||||
});
|
||||
assertThat(wrapper).hasValueSatisfying(it -> assertThat(it.getLastModifiedDate()).isEqualTo(expected));
|
||||
}
|
||||
|
||||
static class Sample {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
package org.springframework.data.auditing.config;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
Reference in New Issue
Block a user