diff --git a/common/src/test/groovy/dvoraka/avservice/common/replication/ReplicationServiceHelperSpec.groovy b/common/src/test/groovy/dvoraka/avservice/common/replication/ReplicationServiceHelperSpec.groovy index c9c0a60f..0b9002d0 100644 --- a/common/src/test/groovy/dvoraka/avservice/common/replication/ReplicationServiceHelperSpec.groovy +++ b/common/src/test/groovy/dvoraka/avservice/common/replication/ReplicationServiceHelperSpec.groovy @@ -46,7 +46,8 @@ class ReplicationServiceHelperSpec extends Specification { def "exists reply"() { when: - ReplicationMessage request = helper.createExistsRequest(testFilename, testOwner, testId) + ReplicationMessage request = helper.createExistsRequest( + testFilename, testOwner, testId) result = helper.createExistsReply(request, otherId) then: @@ -66,7 +67,8 @@ class ReplicationServiceHelperSpec extends Specification { def "status OK reply"() { when: - ReplicationMessage request = helper.createStatusRequest(testFilename, testOwner, testId) + ReplicationMessage request = helper.createStatusRequest( + testFilename, testOwner, testId) result = helper.createOkStatusReply(request, otherId) then: @@ -112,7 +114,8 @@ class ReplicationServiceHelperSpec extends Specification { def "lock success reply"() { when: - ReplicationMessage request = helper.createLockRequest(testFilename, testOwner, testId, testSequence) + ReplicationMessage request = helper.createLockRequest( + testFilename, testOwner, testId, testSequence) result = helper.createLockSuccessReply(request, otherId) then: @@ -124,6 +127,23 @@ class ReplicationServiceHelperSpec extends Specification { result.getOwner() == testOwner } + def "lock failed reply"() { + when: + ReplicationMessage request = helper.createLockRequest( + testFilename, testOwner, testId, testSequence) + result = helper.createLockFailReply(request, testSequence, otherId) + + then: + checkReplyBase(result) + result.getCommand() == Command.LOCK + result.getReplicationStatus() == ReplicationStatus.FAILED + + result.getSequence() == testSequence + + result.getFilename() == testFilename + result.getOwner() == testOwner + } + def "unlock request"() { when: result = helper.createUnlockRequest(testFilename, testOwner, testId, testSequence) @@ -134,6 +154,21 @@ class ReplicationServiceHelperSpec extends Specification { result.getSequence() == testSequence } + def "unlock success reply"() { + when: + ReplicationMessage request = helper.createUnlockRequest( + testFilename, testOwner, testId, testSequence) + result = helper.createUnlockSuccessReply(request, otherId) + + then: + checkReplyBase(result) + result.getCommand() == Command.UNLOCK + result.getReplicationStatus() == ReplicationStatus.OK + + result.getFilename() == testFilename + result.getOwner() == testOwner + } + def "sequence request"() { when: result = helper.createSequenceRequest(testId) @@ -148,6 +183,17 @@ class ReplicationServiceHelperSpec extends Specification { result.getToId() == null } + def "sequence reply"() { + when: + ReplicationMessage request = helper.createSequenceRequest(testId) + result = helper.createSequenceReply(request, otherId, testSequence) + + then: + checkReplyBase(result) + result.getCommand() == Command.SEQUENCE + result.getSequence() == testSequence + } + void checkRequestBase(ReplicationMessage message) { assert message.getType() == MessageType.REPLICATION_SERVICE assert message.getRouting() == MessageRouting.BROADCAST