### Question:
DeFiBusClientHookFactory { public static RPCHook createRPCHook(final RPCHook rpcHook) { return new RPCHook() { @Override public void doBeforeRequest(String remoteAddr, RemotingCommand request) { if (rpcHook != null) { rpcHook.doBeforeRequest(remoteAddr, request); } } @Override public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) { } }; }  static RPCHook createRPCHook(final RPCHook rpcHook);  }### Answer:
@Test public void test() { DeFiBusClientHookFactory.createRPCHook(null); }
@Test public void test_doBefore_doAfter() { AtomicInteger invokeTimes = new AtomicInteger(0); RPCHook rpcHook = new RPCHook() { @Override public void doBeforeRequest(String remoteAddr, RemotingCommand request) { invokeTimes.getAndIncrement(); } @Override public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) { invokeTimes.getAndIncrement(); } }; DeFiBusClientHookFactory.createRPCHook(rpcHook); rpcHook.doBeforeRequest("", null); assertThat(invokeTimes.get()).isEqualTo(1); rpcHook.doAfterResponse("", null, null); assertThat(invokeTimes.get()).isEqualTo(2); }