MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / getMockHBaseRpc

Method getMockHBaseRpc

test/BaseTestHBaseClient.java:400–417  ·  view source on GitHub ↗

Generate and return a mocked HBase RPC for testing purposes with a valid Deferred that can be called on execution. @param deferred A deferred to watch for results @return The RPC to pass through unit tests.

(final Deferred<Object> deferred)

Source from the content-addressed store, hash-verified

398 * @return The RPC to pass through unit tests.
399 */
400 protected HBaseRpc getMockHBaseRpc(final Deferred<Object> deferred) {
401 final HBaseRpc rpc = mock(HBaseRpc.class);
402 rpc.attempt = 0;
403 when(rpc.getDeferred()).thenReturn(deferred);
404 when(rpc.toString()).thenReturn("MockRPC");
405 PowerMockito.doAnswer(new Answer<Void>() {
406 @Override
407 public Void answer(InvocationOnMock invocation) throws Throwable {
408 if (deferred != null) {
409 deferred.callback(invocation.getArguments()[0]);
410 } else {
411 System.out.println("Deferred was null!!");
412 }
413 return null;
414 }
415 }).when(rpc).callback(Object.class);
416 return rpc;
417 }
418}

Callers 2

tooManyAttemptsMethod · 0.80

Calls 3

getDeferredMethod · 0.95
toStringMethod · 0.95
callbackMethod · 0.45

Tested by

no test coverage detected