From 9dcf919207d9176a1f657ee7136a5ccc03d840b1 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 19 Mar 2013 17:44:39 +0100 Subject: [PATCH] DATAJPA-303 - Added integration test to show auditing on update working. --- .../support/AuditingEntityListenerTests.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/springframework/data/jpa/domain/support/AuditingEntityListenerTests.java b/src/test/java/org/springframework/data/jpa/domain/support/AuditingEntityListenerTests.java index 3359092bf..2c9bdc6dc 100644 --- a/src/test/java/org/springframework/data/jpa/domain/support/AuditingEntityListenerTests.java +++ b/src/test/java/org/springframework/data/jpa/domain/support/AuditingEntityListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2011 the original author or authors. + * Copyright 2008-2013 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. @@ -57,18 +57,32 @@ public class AuditingEntityListenerTests { user = new AuditableUser(); auditorAware.setAuditor(user); - repository.save(user); + repository.saveAndFlush(user); } @Test - public void auditsRootEntityCorrectly() throws Exception { + public void auditsRootEntityCorrectly() { assertDatesSet(user); assertUserIsAuditor(user, user); } + /** + * @see DATAJPA-303 + */ @Test - public void auditsTransitiveEntitiesCorrectly() throws Exception { + public void updatesLastModifiedDates() throws Exception { + + Thread.sleep(200); + user.setFirstname("Oliver"); + + user = repository.saveAndFlush(user); + + assertThat(user.getCreatedDate().isBefore(user.getLastModifiedDate()), is(true)); + } + + @Test + public void auditsTransitiveEntitiesCorrectly() { AuditableRole role = new AuditableRole(); role.setName("ADMIN");