@Override public Void answer(InvocationOnMock invocation) throws Throwable { processor.process(new SegmentAttributeUpdated(1, true)); return null; } }).when(connection).sendAsync(Mockito.eq(new WireCommands.UpdateSegmentAttribute(1, segment.getScopedName(), attributeId, 1234,
@Override public Void answer(InvocationOnMock invocation) throws Throwable { processor.process(new WireCommands.SegmentAttribute(1, 123)); return null; } }).when(connection).sendAsync(Mockito.eq(new WireCommands.GetSegmentAttribute(1, segment.getScopedName(), attributeId, "")),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { processor.get().process(new StreamSegmentInfo(3, segment.getScopedName(), true, false, false, 0, 123, 121)); return null; } }).when(connection2).sendAsync(Mockito.eq(getSegmentInfo2), Mockito.any(ClientConnection.CompletedCallback.class));
@Override public Void answer(InvocationOnMock invocation) throws Throwable { processor.process(new StreamSegmentInfo(1, segment.getScopedName(), true, false, false, 0, 123, 121)); return null; } }).when(connection).sendAsync(Mockito.eq(new WireCommands.GetStreamSegmentInfo(1, segment.getScopedName(), "")),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { processor.process(new SegmentTruncated(1, segment.getScopedName())); return null; } }).when(connection).sendAsync(Mockito.eq(new WireCommands.TruncateSegment(1, segment.getScopedName(), 123L, "")),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { processor.process(new WireCommands.SegmentSealed(1, segment.getScopedName())); return null; } }).when(connection).sendAsync(Mockito.eq(new WireCommands.SealSegment(1, segment.getScopedName(), "")),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { ConditionalAppend argument = (ConditionalAppend) invocation.getArgument(0); ReplyProcessor processor = connectionFactory.getProcessor(location); if (replies.take()) { processor.process(new WireCommands.DataAppended(argument.getWriterId(), argument.getEventNumber(), 0)); } else { processor.process(new WireCommands.ConditionalCheckFailed(argument.getWriterId(), argument.getEventNumber())); } return null; } }).when(mock).sendAsync(any(ConditionalAppend.class), any(ClientConnection.CompletedCallback.class));
@Override public Void answer(InvocationOnMock invocation) throws Throwable { ConditionalAppend argument = (ConditionalAppend) invocation.getArgument(0); ReplyProcessor processor = connectionFactory.getProcessor(location); if (count.getAndIncrement() < 2) { processor.connectionDropped(); } else { processor.process(new WireCommands.DataAppended(argument.getWriterId(), argument.getEventNumber(), 0)); } return null; } }).when(mock).sendAsync(any(ConditionalAppend.class), any(ClientConnection.CompletedCallback.class));
@Override public Void answer(InvocationOnMock invocation) throws Throwable { WireCommands.CreateSegment request = (WireCommands.CreateSegment) invocation.getArgument(0); connectionFactory.getProcessor(location) .process(new WireCommands.SegmentCreated(request.getRequestId(), request.getSegment())); return null; } }).when(connection).sendAsync(Mockito.any(WireCommands.CreateSegment.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { CreateSegment request = (CreateSegment) invocation.getArgument(0); connectionFactory.getProcessor(endpoint) .process(new SegmentCreated(request.getRequestId(), request.getSegment())); return null; } }).when(connection).sendAsync(Mockito.any(CreateSegment.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { GetStreamSegmentInfo request = (GetStreamSegmentInfo) invocation.getArgument(0); connectionFactory.getProcessor(location) .process(new StreamSegmentInfo(request.getRequestId(), request.getSegmentName(), true, false, false, 0, 0, 0)); return null; } }).when(connection).sendAsync(Mockito.any(GetStreamSegmentInfo.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { WireCommands.GetStreamSegmentInfo request = (WireCommands.GetStreamSegmentInfo) invocation.getArgument(0); connectionFactory.getProcessor(location) .process(new WireCommands.StreamSegmentInfo(request.getRequestId(), request.getSegmentName(), true, false, false, 0, 0, 0)); return null; } }).when(connection).sendAsync(Mockito.any(WireCommands.GetStreamSegmentInfo.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { ReplyProcessor processor = cf.getProcessor(endpoint); processor.process(new StreamSegmentInfo(2, segment.getScopedName(), true, false, false, 0, 123, 121)); return null; } }).when(connection).sendAsync(Mockito.eq(getSegmentInfo2), Mockito.any(ClientConnection.CompletedCallback.class));
@Override public Void answer(InvocationOnMock invocation) throws Throwable { CreateSegment request = (CreateSegment) invocation.getArgument(0); connectionFactory.getProcessor(location) .process(new SegmentCreated(request.getRequestId(), request.getSegment())); return null; } }).when(connection).sendAsync(Mockito.any(CreateSegment.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { ConditionalAppend argument = (ConditionalAppend) invocation.getArgument(0); ReplyProcessor processor = connectionFactory.getProcessor(location); processor.process(new WireCommands.SegmentIsSealed(argument.getEventNumber(), segment.getScopedName(), mockClientReplyStackTrace)); return null; } }).when(mock).sendAsync(any(ConditionalAppend.class), any(ClientConnection.CompletedCallback.class));
@Override public Void answer(InvocationOnMock invocation) throws Throwable { CreateSegment request = (CreateSegment) invocation.getArgument(0); connectionFactory.getProcessor(endpoint) .process(new SegmentCreated(request.getRequestId(), request.getSegment())); return null; } }).when(connection).sendAsync(Mockito.any(CreateSegment.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { CreateSegment request = (CreateSegment) invocation.getArgument(0); connectionFactory.getProcessor(location) .process(new SegmentCreated(request.getRequestId(), request.getSegment())); return null; } }).when(connection).sendAsync(Mockito.any(CreateSegment.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { GetStreamSegmentInfo request = (GetStreamSegmentInfo) invocation.getArgument(0); connectionFactory.getProcessor(location) .process(new StreamSegmentInfo(request.getRequestId(), request.getSegmentName(), true, false, false, 0, 0, 0)); return null; } }).when(connection).sendAsync(Mockito.any(GetStreamSegmentInfo.class),
@Override public Void answer(InvocationOnMock invocation) throws Throwable { ConditionalAppend argument = (ConditionalAppend) invocation.getArgument(0); ReplyProcessor processor = connectionFactory.getProcessor(location); if (argument.getExpectedOffset() == 0 || argument.getExpectedOffset() == 2) { processor.process(new WireCommands.DataAppended(argument.getWriterId(), argument.getEventNumber(), 0)); } else { processor.process(new WireCommands.ConditionalCheckFailed(argument.getWriterId(), argument.getEventNumber())); } return null; } }).when(mock).sendAsync(any(ConditionalAppend.class), any(ClientConnection.CompletedCallback.class));
@Override public Void answer(InvocationOnMock invocation) throws Throwable { SetupAppend argument = (SetupAppend) invocation.getArgument(0); connectionFactory.getProcessor(location) .process(new AppendSetup(argument.getRequestId(), segment.getScopedName(), argument.getWriterId(), 0)); return null; } }).when(mock).sendAsync(any(SetupAppend.class), any(ClientConnection.CompletedCallback.class));