Skip to content

Commit

Permalink
DATACMNS-187 - Added getRevisionDate() to Revision.
Browse files Browse the repository at this point in the history
Revision now exposes the revision date of the underlying metadata.
  • Loading branch information
odrotbohm committed Jul 16, 2012
1 parent 4d326fa commit 464c3f0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.history;

import org.joda.time.DateTime;
import org.springframework.util.Assert;

/**
Expand Down Expand Up @@ -52,6 +53,15 @@ public N getRevisionNumber() {
return metadata.getRevisionNumber();
}

/**
* Returns the revision date of the revision.
*
* @return
*/
public DateTime getRevisionDate() {
return metadata.getRevisionDate();
}

/**
* Returns the underlying entity.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collections;
import java.util.List;

import org.joda.time.DateTime;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
Expand Down Expand Up @@ -55,4 +56,31 @@ public void comparesCorrectly() {
assertThat(revisions.get(0), is(first));
assertThat(revisions.get(1), is(second));
}

/**
* @see DATACMNS-187
*/
@Test
public void returnsRevisionNumber() {

when(firstMetadata.getRevisionNumber()).thenReturn(4711);

Revision<Integer, Object> revision = new Revision<Integer, Object>(firstMetadata, new Object());

assertThat(revision.getRevisionNumber(), is(4711));
}

/**
* @see DATACMNS-187
*/
@Test
public void returnsRevisionDate() {

DateTime reference = new DateTime();
when(firstMetadata.getRevisionDate()).thenReturn(reference);

Revision<Integer, Object> revision = new Revision<Integer, Object>(firstMetadata, new Object());

assertThat(revision.getRevisionDate(), is(reference));
}
}

0 comments on commit 464c3f0

Please sign in to comment.