diff --git a/src/test/java/com/bitpay/sdk/ClientTest.java b/src/test/java/com/bitpay/sdk/ClientTest.java index 32bbb275..d5bc7642 100644 --- a/src/test/java/com/bitpay/sdk/ClientTest.java +++ b/src/test/java/com/bitpay/sdk/ClientTest.java @@ -663,8 +663,7 @@ public void it_should_create_refund() throws BitPayApiException, BitPayGenericEx Mockito.when(this.bitPayClient.post("refunds/", createRefundJsonRequest, true)) .thenReturn( this.getHttpResponseWithSpecificBody(getPreparedJsonDataFromFile("createRefundResponse.json"))); - Mockito.when(this.guidGenerator.execute()).thenReturn(EXAMPLE_UUID); - Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken); + this.stubGuidAndAccessToken(Facade.MERCHANT, merchantToken); Client testedClass = this.getTestedClass(); // when @@ -1556,8 +1555,7 @@ public void it_should_test_updatePayoutRecipient() throws BitPayApiException, Bi payoutRecipient.setLabel(label); payoutRecipient.setToken(PAYOUT_ACCESS_TOKEN); - Mockito.when(this.guidGenerator.execute()).thenReturn(EXAMPLE_UUID); - Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN); + this.stubGuidAndAccessToken(Facade.PAYOUT, PAYOUT_ACCESS_TOKEN); Mockito.when(this.bitPayClient.update( "recipients/" + RECIPIENT_ID, getPreparedJsonDataFromFile("updatePayoutRecipientRequest.json") @@ -2104,4 +2102,12 @@ private Client getTestedClass() { this.guidGenerator ); } + + private void stubGuidAndAccessToken( + Facade facade, + String accessToken + ) throws BitPayGenericException { + Mockito.when(this.guidGenerator.execute()).thenReturn(EXAMPLE_UUID); + Mockito.when(this.accessTokens.getAccessToken(facade)).thenReturn(accessToken); + } }