@Test(timeout = 10000) public void testTruncate() throws Exception { Segment segment = new Segment("scope", "testTruncate", 4); PravegaNodeUri endpoint = new PravegaNodeUri("localhost", 0); @Cleanup MockConnectionFactoryImpl cf = new MockConnectionFactoryImpl(); @Cleanup MockController controller = new MockController(endpoint.getEndpoint(), endpoint.getPort(), cf); @Cleanup ClientConnection connection = mock(ClientConnection.class); cf.provideConnection(endpoint, connection); @Cleanup SegmentMetadataClientImpl client = new SegmentMetadataClientImpl(segment, controller, cf, ""); client.getConnection(); ReplyProcessor processor = cf.getProcessor(endpoint); Mockito.doAnswer(new Answer<Void>() { @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, "")), Mockito.any(ClientConnection.CompletedCallback.class)); client.truncateSegment(123L); Mockito.verify(connection).sendAsync(Mockito.eq(new WireCommands.TruncateSegment(1, segment.getScopedName(), 123L, "")), Mockito.any(ClientConnection.CompletedCallback.class)); }