Skip to content

Commit

Permalink
#225 Improve tests and implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoraka committed May 11, 2017
1 parent 9174caf commit 47643fa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public void add(ReplicationMessage message) {
public Stream<ReplicationMessage> stream() {
return messages.stream();
}

public int size() {
return messages.size();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package dvoraka.avservice.client.service.response

import dvoraka.avservice.common.replication.ReplicationHelper
import spock.lang.Specification
import spock.lang.Subject

/**
* List spec.
*/
class ReplicationMessageListSpec extends Specification implements ReplicationHelper {

@Subject
ReplicationMessageList messages


def setup() {
messages = new ReplicationMessageList()
}

def "add message"() {
expect:
messages.size() == 0

when:
messages.add(createDiscoverRequest('node ID'))

then:
messages.size() == 1
}

def "get stream"() {
expect:
messages.size() == 0

when:
messages.add(createDiscoverRequest('node ID'))
messages.add(createDiscoverRequest('node ID'))

then:
messages.stream().count() == 2
}
}

0 comments on commit 47643fa

Please sign in to comment.