final String accessSecret = "accessSecret";
final SpreedlyInvoker spreedlyInvoker = new SpreedlyInvoker(environmentKey, accessSecret, client);
final String targetUrl = "http://target.url";
final String method = "POST";
final Transaction transaction = new Transaction();
final PaymentMethod returnPaymentMethod = new PaymentMethod();
//set up mocks
final WebTarget webTarget = mock(WebTarget.class);
when(client.target(targetUrl)).thenReturn(webTarget);
final Invocation.Builder builder = mock(Invocation.Builder.class);
when(webTarget.request()).thenReturn(builder);
when(builder.header(anyString(), any())).thenReturn(builder);
final Response response = mock(Response.class);
when(builder.method(eq(method), any(Entity.class))).thenReturn(response);
when(response.getStatus()).thenReturn(200); //success response
when(response.readEntity(PaymentMethod.class)).thenReturn(returnPaymentMethod);
//method under test
final PaymentMethod responsePaymentMethod = spreedlyInvoker.invoke(targetUrl, method, transaction, PaymentMethod.class);
//assertions
assertNotNull(responsePaymentMethod);
assertEquals(returnPaymentMethod, responsePaymentMethod);