private SourceSequence setUpSequence(String sid,
Long[] messageNumbers,
boolean[] isAcked) {
SourceSequence sequence = createMock(SourceSequence.class);
Identifier id = createMock(Identifier.class);
sequence.getIdentifier();
EasyMock.expectLastCall().andReturn(id);
id.getValue();
EasyMock.expectLastCall().andReturn(sid);
identifiers.add(id);
boolean includesAcked = false;
for (int i = 0; isAcked != null && i < isAcked.length; i++) {
sequence.isAcknowledged(messageNumbers[i]);
EasyMock.expectLastCall().andReturn(isAcked[i]);
if (isAcked[i]) {
includesAcked = true;
}
}
if (includesAcked) {
// Will be called once or twice depending on whether any more
// unacknowledged messages are left for this sequence
sequence.getIdentifier();
EasyMock.expectLastCall().andReturn(id).times(1, 2);
// Would be called only when there are no more
// unacknowledged messages left for this sequence
id.getValue();
EasyMock.expectLastCall().andReturn(sid).times(0, 1);
RMStore store = createMock(RMStore.class);
manager.getStore();
EasyMock.expectLastCall().andReturn(store);