AergoPool implements ResourcePool<AergoApi> { @Override public void returnResource(final AergoApi resource) { tryClose(resource); }  @Override AergoApi borrowResource(); @Override void returnResource(final AergoApi resource);  }
@Test @PrepareForTest(AergoClientBuilder.class) @SuppressWarnings("unchecked") public void testReturnResource() throws Exception { final ConnectStrategy<ManagedChannel> connectStrategy = mock(ConnectStrategy.class); final AergoClient client = mock(AergoClient.class); whenNew(AergoClient.class).withAnyArguments().thenReturn(client); final AergoPool pool = new AergoPool(randomUUID().toString()); final AergoApi api = pool.borrowResource(); pool.returnResource(api); verify((AergoClient) api).close(); }