Skip to content

Commit

Permalink
[revisions] improve test coverage on JaversRevisionService
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichel35 committed Jul 31, 2015
1 parent 18018e6 commit 0f9957c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public Object getSnapshot(String objectID, Class<?> objectClass, String commitID

}

private CdoSnapshot findCdoSnapshotByCommit(Commit commit) {
public CdoSnapshot findCdoSnapshotByCommit(Commit commit) {

String id = commit.getObjectID();
Class<?> clazz = commit.getObjectClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class JaversRevisionServiceTest extends Specification {

}

def "it should compare to version of the same object"() {
def "it should compare two versions of the same object"() {

given:
def old = new DomainObject(id: "1")
Expand All @@ -78,4 +78,63 @@ class JaversRevisionServiceTest extends Specification {

}

def "it should retrieve a commit in the history from its ID"() {

given:
def objectID = "1"
def objectClass = DomainObject.class
def commitID = "2"
def history = [new Commit(id: "3"), new Commit(id: "2"), new Commit(id: "1")]

and:
def JaversRevisionService service = Spy()

when:
def commit = service.findCommitByID(objectID, objectClass, commitID)

then:
service.getHistory(objectID, objectClass) >> history

then:
commit == history[1]
notThrown(Exception.class)

}

def "it should return the previous commit from a commit ID"() {

given:
def objectID = "1"
def objectClass = DomainObject.class
def commitID = "2"
def history = [new Commit(id: "3"), new Commit(id: "2"), new Commit(id: "1")]

and:
def JaversRevisionService service = Spy()

when:
def commit = service.getPreviousCommit(objectID, objectClass, commitID)

then:
service.getHistory(objectID, objectClass) >> history

then:
commit == history[2]
notThrown(Exception.class)

}

def "it should find a Javers CdoSnapshot instance by commit data"() {

given:
def commit = new Commit(id: "1", objectID: "1", objectClass: DomainObject.class)

when:
revisionService.findCdoSnapshotByCommit(commit)

then:
1 * javers.findSnapshots(_)
notThrown(Exception.class)
}

}

0 comments on commit 0f9957c

Please sign in to comment.