DATACMNS-414 - Removed unnecessary generic types for AuditingHandler.
Removed the unnecessary type arguments for AuditingHandler so that the setter taking an AuditorAware<T> can be successfully wired against implementations other than AuditorAware<Object> with Spring 4. The type argument was superfluous anyway as internally the type wasn't referred to and the handler is not used on a by-type basis.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.data.domain.AuditorAware;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AuditingHandlerUnitTests {
|
||||
|
||||
AuditingHandler<AuditedUser> handler;
|
||||
AuditingHandler handler;
|
||||
AuditorAware<AuditedUser> auditorAware;
|
||||
|
||||
AuditedUser user;
|
||||
@@ -46,8 +46,8 @@ public class AuditingHandlerUnitTests {
|
||||
when(auditorAware.getCurrentAuditor()).thenReturn(user);
|
||||
}
|
||||
|
||||
protected AuditingHandler<AuditedUser> getHandler() {
|
||||
return new AuditingHandler<AuditedUser>();
|
||||
protected AuditingHandler getHandler() {
|
||||
return new AuditingHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,6 +149,6 @@ public class AuditingHandlerUnitTests {
|
||||
handler.setDateTimeProvider(provider);
|
||||
handler.markCreated(user);
|
||||
|
||||
verify(provider, times(1)).getDateTime();
|
||||
verify(provider, times(1)).getNow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 the original author or authors.
|
||||
* Copyright 2008-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,10 +37,8 @@ import org.springframework.data.support.IsNewStrategyFactory;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests {
|
||||
|
||||
@Mock
|
||||
IsNewStrategyFactory factory;
|
||||
@Mock
|
||||
IsNewStrategy strategy;
|
||||
@Mock IsNewStrategyFactory factory;
|
||||
@Mock IsNewStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -48,8 +46,8 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IsNewAwareAuditingHandler<AuditedUser> getHandler() {
|
||||
return new IsNewAwareAuditingHandler<AuditedUser>(factory);
|
||||
protected IsNewAwareAuditingHandler getHandler() {
|
||||
return new IsNewAwareAuditingHandler(factory);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,6 +18,9 @@ package org.springframework.data.auditing;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -37,11 +40,14 @@ public class ReflectionAuditingBeanWrapperUnitTests {
|
||||
AnnotatedUser user;
|
||||
AuditableBeanWrapper wrapper;
|
||||
|
||||
DateTime time = new DateTime();
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
DateTime time = new DateTime(calendar);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
assertThat(time, is(new DateTime(calendar)));
|
||||
|
||||
this.user = new AnnotatedUser();
|
||||
this.wrapper = new ReflectionAuditingBeanWrapper(user);
|
||||
}
|
||||
@@ -49,14 +55,14 @@ public class ReflectionAuditingBeanWrapperUnitTests {
|
||||
@Test
|
||||
public void setsDateTimeFieldCorrectly() {
|
||||
|
||||
wrapper.setCreatedDate(time);
|
||||
wrapper.setCreatedDate(calendar);
|
||||
assertThat(user.createdDate, is(time));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setsDateFieldCorrectly() {
|
||||
|
||||
wrapper.setLastModifiedDate(time);
|
||||
wrapper.setLastModifiedDate(calendar);
|
||||
assertThat(user.lastModifiedDate, is(time.toDate()));
|
||||
}
|
||||
|
||||
@@ -73,10 +79,10 @@ public class ReflectionAuditingBeanWrapperUnitTests {
|
||||
Sample sample = new Sample();
|
||||
AuditableBeanWrapper wrapper = new ReflectionAuditingBeanWrapper(sample);
|
||||
|
||||
wrapper.setCreatedDate(time);
|
||||
wrapper.setCreatedDate(calendar);
|
||||
assertThat(sample.createdDate, is(time.getMillis()));
|
||||
|
||||
wrapper.setLastModifiedDate(time);
|
||||
wrapper.setLastModifiedDate(calendar);
|
||||
assertThat(sample.modifiedDate, is(time.getMillis()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user