DATACMNS-1718 - Migrate tests to JUnit 5.
This commit is contained in:
@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Oliver Gierke
|
||||
* @since 1.5
|
||||
*/
|
||||
public class AnnotationAuditingMetadataUnitTests {
|
||||
class AnnotationAuditingMetadataUnitTests {
|
||||
|
||||
static final Field createdByField = ReflectionUtils.findField(AnnotatedUser.class, "createdBy");
|
||||
static final Field createdDateField = ReflectionUtils.findField(AnnotatedUser.class, "createdDate");
|
||||
@@ -39,7 +39,7 @@ public class AnnotationAuditingMetadataUnitTests {
|
||||
static final Field lastModifiedDateField = ReflectionUtils.findField(AnnotatedUser.class, "lastModifiedDate");
|
||||
|
||||
@Test
|
||||
public void checkAnnotationDiscovery() {
|
||||
void checkAnnotationDiscovery() {
|
||||
|
||||
AnnotationAuditingMetadata metadata = AnnotationAuditingMetadata.getMetadata(AnnotatedUser.class);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AnnotationAuditingMetadataUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkCaching() {
|
||||
void checkCaching() {
|
||||
|
||||
AnnotationAuditingMetadata firstCall = AnnotationAuditingMetadata.getMetadata(AnnotatedUser.class);
|
||||
assertThat(firstCall).isNotNull();
|
||||
@@ -61,7 +61,7 @@ public class AnnotationAuditingMetadataUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkIsAuditable() {
|
||||
void checkIsAuditable() {
|
||||
|
||||
AnnotationAuditingMetadata metadata = AnnotationAuditingMetadata.getMetadata(AnnotatedUser.class);
|
||||
assertThat(metadata).isNotNull();
|
||||
@@ -73,7 +73,7 @@ public class AnnotationAuditingMetadataUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsInvalidDateTypeField() {
|
||||
void rejectsInvalidDateTypeField() {
|
||||
|
||||
class Sample {
|
||||
@CreatedDate String field;
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
@@ -39,15 +39,15 @@ import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
* @since 1.5
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AuditingHandlerUnitTests {
|
||||
class AuditingHandlerUnitTests {
|
||||
|
||||
AuditingHandler handler;
|
||||
AuditorAware<AuditedUser> auditorAware;
|
||||
|
||||
AuditedUser user;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
handler = getHandler();
|
||||
user = new AuditedUser();
|
||||
@@ -64,7 +64,7 @@ public class AuditingHandlerUnitTests {
|
||||
* Checks that the advice does not set auditor on the target entity if no {@code AuditorAware} was configured.
|
||||
*/
|
||||
@Test
|
||||
public void doesNotSetAuditorIfNotConfigured() {
|
||||
void doesNotSetAuditorIfNotConfigured() {
|
||||
|
||||
handler.markCreated(user);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class AuditingHandlerUnitTests {
|
||||
* Checks that the advice sets the auditor on the target entity if an {@code AuditorAware} was configured.
|
||||
*/
|
||||
@Test
|
||||
public void setsAuditorIfConfigured() {
|
||||
void setsAuditorIfConfigured() {
|
||||
|
||||
handler.setAuditorAware(auditorAware);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class AuditingHandlerUnitTests {
|
||||
* Checks that the advice does not set modification information on creation if the falg is set to {@code false}.
|
||||
*/
|
||||
@Test
|
||||
public void honoursModifiedOnCreationFlag() {
|
||||
void honoursModifiedOnCreationFlag() {
|
||||
|
||||
handler.setAuditorAware(auditorAware);
|
||||
handler.setModifyOnCreation(false);
|
||||
@@ -117,7 +117,7 @@ public class AuditingHandlerUnitTests {
|
||||
* Tests that the advice only sets modification data if a not-new entity is handled.
|
||||
*/
|
||||
@Test
|
||||
public void onlySetsModificationDataOnNotNewEntities() {
|
||||
void onlySetsModificationDataOnNotNewEntities() {
|
||||
|
||||
AuditedUser audited = new AuditedUser();
|
||||
audited.id = 1L;
|
||||
@@ -135,7 +135,7 @@ public class AuditingHandlerUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotSetTimeIfConfigured() {
|
||||
void doesNotSetTimeIfConfigured() {
|
||||
|
||||
handler.setDateTimeForNow(false);
|
||||
handler.setAuditorAware(auditorAware);
|
||||
@@ -149,7 +149,7 @@ public class AuditingHandlerUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATAJPA-9
|
||||
public void usesDateTimeProviderIfConfigured() {
|
||||
void usesDateTimeProviderIfConfigured() {
|
||||
|
||||
DateTimeProvider provider = mock(DateTimeProvider.class);
|
||||
doReturn(Optional.empty()).when(provider).getNow();
|
||||
@@ -161,7 +161,7 @@ public class AuditingHandlerUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setsAuditingInfoOnEntityUsingInheritance() {
|
||||
void setsAuditingInfoOnEntityUsingInheritance() {
|
||||
|
||||
AuditingHandler handler = new AuditingHandler(PersistentEntities.of(new SampleMappingContext()));
|
||||
handler.setModifyOnCreation(false);
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
@@ -40,36 +40,36 @@ import org.springframework.data.auditing.DefaultAuditableBeanWrapperFactory.Refl
|
||||
* @author Jens Schauder
|
||||
* @since 1.5
|
||||
*/
|
||||
public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
|
||||
DefaultAuditableBeanWrapperFactory factory = new DefaultAuditableBeanWrapperFactory();
|
||||
|
||||
@Test
|
||||
public void rejectsNullSource() {
|
||||
void rejectsNullSource() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factory.getBeanWrapperFor(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsAuditableInterfaceBeanWrapperForAuditable() {
|
||||
void returnsAuditableInterfaceBeanWrapperForAuditable() {
|
||||
|
||||
assertThat(factory.getBeanWrapperFor(new AuditedUser()))
|
||||
.hasValueSatisfying(it -> assertThat(it).isInstanceOf(AuditableInterfaceBeanWrapper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsReflectionAuditingBeanWrapperForNonAuditableButAnnotated() {
|
||||
void returnsReflectionAuditingBeanWrapperForNonAuditableButAnnotated() {
|
||||
|
||||
assertThat(factory.getBeanWrapperFor(new AnnotatedUser()))
|
||||
.hasValueSatisfying(it -> assertThat(it).isInstanceOf(ReflectionAuditingBeanWrapper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsEmptyForNonAuditableType() {
|
||||
void returnsEmptyForNonAuditableType() {
|
||||
assertThat(factory.getBeanWrapperFor(new Object())).isNotPresent();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-643
|
||||
public void setsJsr310AndThreeTenBpTypes() {
|
||||
void setsJsr310AndThreeTenBpTypes() {
|
||||
|
||||
Jsr310ThreeTenBpAuditedUser user = new Jsr310ThreeTenBpAuditedUser();
|
||||
Instant instant = Instant.now();
|
||||
@@ -87,7 +87,7 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-867
|
||||
public void errorsWhenUnableToConvertDateViaIntermediateJavaUtilDateConversion() {
|
||||
void errorsWhenUnableToConvertDateViaIntermediateJavaUtilDateConversion() {
|
||||
|
||||
Jsr310ThreeTenBpAuditedUser user = new Jsr310ThreeTenBpAuditedUser();
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.now();
|
||||
@@ -101,7 +101,7 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1259
|
||||
public void lastModifiedDateAsLongIsAvailableViaWrapper() {
|
||||
void lastModifiedDateAsLongIsAvailableViaWrapper() {
|
||||
|
||||
LongBasedAuditable source = new LongBasedAuditable();
|
||||
source.dateModified = 42000L;
|
||||
@@ -114,7 +114,7 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1259
|
||||
public void canSetLastModifiedDateAsInstantViaWrapperOnLongField() {
|
||||
void canSetLastModifiedDateAsInstantViaWrapperOnLongField() {
|
||||
|
||||
LongBasedAuditable source = new LongBasedAuditable();
|
||||
|
||||
@@ -127,7 +127,7 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1259
|
||||
public void canSetLastModifiedDateAsLocalDateTimeViaWrapperOnLongField() {
|
||||
void canSetLastModifiedDateAsLocalDateTimeViaWrapperOnLongField() {
|
||||
|
||||
LongBasedAuditable source = new LongBasedAuditable();
|
||||
|
||||
@@ -140,7 +140,7 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1259
|
||||
public void lastModifiedAsLocalDateTimeDateIsAvailableViaWrapperAsLocalDateTime() {
|
||||
void lastModifiedAsLocalDateTimeDateIsAvailableViaWrapperAsLocalDateTime() {
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
|
||||
@@ -19,10 +19,12 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
@@ -34,13 +36,14 @@ import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
* @author Oliver Gierke
|
||||
* @since 1.5
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests {
|
||||
|
||||
SampleMappingContext mappingContext;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@BeforeEach
|
||||
void init() {
|
||||
|
||||
this.mappingContext = new SampleMappingContext();
|
||||
this.mappingContext.getPersistentEntity(AuditedUser.class);
|
||||
@@ -53,7 +56,7 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delegatesToMarkCreatedForNewEntity() {
|
||||
void delegatesToMarkCreatedForNewEntity() {
|
||||
|
||||
AuditedUser user = new AuditedUser();
|
||||
|
||||
@@ -64,7 +67,7 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delegatesToMarkModifiedForNonNewEntity() {
|
||||
void delegatesToMarkModifiedForNonNewEntity() {
|
||||
|
||||
AuditedUser user = new AuditedUser();
|
||||
user.id = 1L;
|
||||
@@ -76,17 +79,17 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void rejectsNullMappingContext() {
|
||||
void rejectsNullMappingContext() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new IsNewAwareAuditingHandler((PersistentEntities) null));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void setsUpHandlerWithMappingContext() {
|
||||
void setsUpHandlerWithMappingContext() {
|
||||
new IsNewAwareAuditingHandler(PersistentEntities.of());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638
|
||||
public void handlingOptionalIsANoOp() {
|
||||
void handlingOptionalIsANoOp() {
|
||||
|
||||
IsNewAwareAuditingHandler handler = getHandler();
|
||||
|
||||
@@ -96,7 +99,7 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
|
||||
}
|
||||
|
||||
@Test // DATACMNS-957
|
||||
public void skipsEntityWithoutIdentifier() {
|
||||
void skipsEntityWithoutIdentifier() {
|
||||
getHandler().markAudited(Optional.of(new EntityWithoutId()));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.data.annotation.LastModifiedDate;
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class Jsr310ThreeTenBpAuditedUser {
|
||||
class Jsr310ThreeTenBpAuditedUser {
|
||||
|
||||
@CreatedDate LocalDateTime createdDate;
|
||||
@LastModifiedDate org.threeten.bp.LocalDateTime lastModifiedDate;
|
||||
|
||||
@@ -33,8 +33,8 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.assertj.core.api.AbstractLongAssert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
@@ -54,12 +54,12 @@ import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
* @author Jens Schauder
|
||||
* @since 1.8
|
||||
*/
|
||||
public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
|
||||
DefaultAuditableBeanWrapperFactory factory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
SampleMappingContext context = new SampleMappingContext();
|
||||
context.getPersistentEntity(Sample.class);
|
||||
@@ -71,7 +71,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void discoversAuditingPropertyOnField() {
|
||||
void discoversAuditingPropertyOnField() {
|
||||
|
||||
Sample sample = new Sample();
|
||||
|
||||
@@ -85,7 +85,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void discoversAuditingPropertyOnAccessor() {
|
||||
void discoversAuditingPropertyOnAccessor() {
|
||||
|
||||
Sample sample = new Sample();
|
||||
|
||||
@@ -99,7 +99,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void settingInavailablePropertyIsNoop() {
|
||||
void settingInavailablePropertyIsNoop() {
|
||||
|
||||
Sample sample = new Sample();
|
||||
|
||||
@@ -109,19 +109,19 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void doesNotReturnWrapperForEntityNotUsingAuditing() {
|
||||
void doesNotReturnWrapperForEntityNotUsingAuditing() {
|
||||
assertThat(factory.getBeanWrapperFor(new NoAuditing())).isNotPresent();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-365
|
||||
public void returnsAuditableWrapperForAuditable() {
|
||||
void returnsAuditableWrapperForAuditable() {
|
||||
|
||||
assertThat(factory.getBeanWrapperFor(mock(ExtendingAuditable.class)))
|
||||
.hasValueSatisfying(it -> assertThat(it).isInstanceOf(AuditableInterfaceBeanWrapper.class));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638
|
||||
public void returnsLastModificationCalendarAsCalendar() {
|
||||
void returnsLastModificationCalendarAsCalendar() {
|
||||
|
||||
Date reference = new Date();
|
||||
|
||||
@@ -133,7 +133,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638
|
||||
public void returnsLastModificationDateTimeAsCalendar() {
|
||||
void returnsLastModificationDateTimeAsCalendar() {
|
||||
|
||||
org.joda.time.LocalDateTime reference = new org.joda.time.LocalDateTime();
|
||||
|
||||
@@ -142,7 +142,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638
|
||||
public void returnsLastModificationDateAsCalendar() {
|
||||
void returnsLastModificationDateAsCalendar() {
|
||||
|
||||
Date reference = new Date();
|
||||
|
||||
@@ -151,7 +151,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638, DATACMNS-43
|
||||
public void returnsLastModificationJsr310DateTimeAsCalendar() {
|
||||
void returnsLastModificationJsr310DateTimeAsCalendar() {
|
||||
|
||||
LocalDateTime reference = LocalDateTime.now();
|
||||
|
||||
@@ -159,7 +159,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-638, DATACMNS-43
|
||||
public void returnsLastModificationThreeTenBpDateTimeAsCalendar() {
|
||||
void returnsLastModificationThreeTenBpDateTimeAsCalendar() {
|
||||
|
||||
org.threeten.bp.LocalDateTime reference = org.threeten.bp.LocalDateTime.now();
|
||||
|
||||
@@ -168,7 +168,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1109
|
||||
public void exposesInstantAsModificationDate() {
|
||||
void exposesInstantAsModificationDate() {
|
||||
|
||||
SampleWithInstant sample = new SampleWithInstant();
|
||||
sample.modified = Instant.now();
|
||||
@@ -180,7 +180,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1259
|
||||
public void exposesLongAsModificationDate() {
|
||||
void exposesLongAsModificationDate() {
|
||||
|
||||
Long reference = new Date().getTime();
|
||||
|
||||
@@ -188,7 +188,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1274
|
||||
public void writesNestedAuditingData() {
|
||||
void writesNestedAuditingData() {
|
||||
|
||||
WithEmbedded target = new WithEmbedded();
|
||||
target.embedded = new Embedded();
|
||||
@@ -217,7 +217,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1461, DATACMNS-1671
|
||||
public void skipsNullIntermediatesWhenSettingProperties() {
|
||||
void skipsNullIntermediatesWhenSettingProperties() {
|
||||
|
||||
WithEmbedded withEmbedded = new WithEmbedded();
|
||||
|
||||
@@ -228,7 +228,7 @@ public class MappingAuditableBeanWrapperFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1438
|
||||
public void skipsCollectionPropertiesWhenSettingProperties() {
|
||||
void skipsCollectionPropertiesWhenSettingProperties() {
|
||||
|
||||
WithEmbedded withEmbedded = new WithEmbedded();
|
||||
withEmbedded.embedded = new Embedded();
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.auditing.DefaultAuditableBeanWrapperFactory.ReflectionAuditingBeanWrapper;
|
||||
@@ -34,7 +34,7 @@ import org.springframework.data.convert.Jsr310Converters.LocalDateTimeToDateConv
|
||||
* @author Oliver Gierke
|
||||
* @since 1.5
|
||||
*/
|
||||
public class ReflectionAuditingBeanWrapperUnitTests {
|
||||
class ReflectionAuditingBeanWrapperUnitTests {
|
||||
|
||||
AnnotationAuditingMetadata metadata;
|
||||
AnnotatedUser user;
|
||||
@@ -42,29 +42,29 @@ public class ReflectionAuditingBeanWrapperUnitTests {
|
||||
|
||||
LocalDateTime time = LocalDateTime.now();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
|
||||
this.user = new AnnotatedUser();
|
||||
this.wrapper = new ReflectionAuditingBeanWrapper(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setsDateTimeFieldCorrectly() {
|
||||
void setsDateTimeFieldCorrectly() {
|
||||
|
||||
wrapper.setCreatedDate(time);
|
||||
assertThat(user.createdDate).isEqualTo(new DateTime(LocalDateTimeToDateConverter.INSTANCE.convert(time)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setsDateFieldCorrectly() {
|
||||
void setsDateFieldCorrectly() {
|
||||
|
||||
wrapper.setLastModifiedDate(time);
|
||||
assertThat(user.lastModifiedDate).isEqualTo(LocalDateTimeToDateConverter.INSTANCE.convert(time));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setsLongFieldCorrectly() {
|
||||
void setsLongFieldCorrectly() {
|
||||
|
||||
class Sample {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ReflectionAuditingBeanWrapperUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setsAuditorFieldsCorrectly() {
|
||||
void setsAuditorFieldsCorrectly() {
|
||||
|
||||
Object object = new Object();
|
||||
|
||||
|
||||
@@ -20,10 +20,11 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
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.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
@@ -38,13 +39,13 @@ import org.springframework.data.auditing.EnableAuditing;
|
||||
* @author Oliver Gierke
|
||||
* @author Francisco Soler
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AuditingBeanDefinitionRegistrarSupportUnitTests {
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class AuditingBeanDefinitionRegistrarSupportUnitTests {
|
||||
|
||||
@Mock BeanDefinitionRegistry registry;
|
||||
|
||||
@Test // DATCMNS-389
|
||||
public void testRegisterBeanDefinitions() {
|
||||
void testRegisterBeanDefinitions() {
|
||||
|
||||
AuditingBeanDefinitionRegistrarSupport registrar = new DummyAuditingBeanDefinitionRegistrarSupport();
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(SampleConfig.class);
|
||||
@@ -54,7 +55,7 @@ public class AuditingBeanDefinitionRegistrarSupportUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1453
|
||||
public void rejectsNullAnnotationMetadata() {
|
||||
void rejectsNullAnnotationMetadata() {
|
||||
|
||||
AuditingBeanDefinitionRegistrarSupport registrar = new DummyAuditingBeanDefinitionRegistrarSupport();
|
||||
|
||||
@@ -63,7 +64,7 @@ public class AuditingBeanDefinitionRegistrarSupportUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1453
|
||||
public void rejectsNullRegistry() {
|
||||
void rejectsNullRegistry() {
|
||||
|
||||
AuditingBeanDefinitionRegistrarSupport registrar = new DummyAuditingBeanDefinitionRegistrarSupport();
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(SampleConfig.class);
|
||||
|
||||
Reference in New Issue
Block a user