diff --git a/src/test/java/com/whatsapp/api/impl/WhatsappBusinessCloudApiTest.java b/src/test/java/com/whatsapp/api/impl/WhatsappBusinessCloudApiTest.java index 71cf17df9..822ea9738 100644 --- a/src/test/java/com/whatsapp/api/impl/WhatsappBusinessCloudApiTest.java +++ b/src/test/java/com/whatsapp/api/impl/WhatsappBusinessCloudApiTest.java @@ -99,7 +99,7 @@ public class WhatsappBusinessCloudApiTest extends MockServerUtilsTest { @Test void testSendMessageError() throws InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(500).setBody("{" +// + mockWebServer.enqueue(new MockResponse().newBuilder().code(500).body("{" +// " \"error\": {\n" +// " \"message\": \"(#130429) Rate limit hit\",\n" +// " \"type\": \"OAuthException\",\n" +// @@ -111,7 +111,7 @@ void testSendMessageError() throws InterruptedException { " \"error_subcode\": 2494055,\n" +// " \"fbtrace_id\": \"Az8or2yhqkZfEZ-_4Qn_Bam\"\n" +// " }\n" +// - "}")); + "}").build()); var message = MessageBuilder.builder()// @@ -135,7 +135,7 @@ void testSendMessageError() throws InterruptedException { @Test void testSendTextMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage1.json"); @@ -159,7 +159,7 @@ void testSendTextMessage() throws IOException, URISyntaxException, InterruptedEx @Test void testSendContactMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage10.json"); @@ -211,7 +211,7 @@ void testSendContactMessage() throws IOException, URISyntaxException, Interrupte @Test void testSendContactMessage2() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage10.json"); @@ -263,7 +263,7 @@ void testSendContactMessage2() throws IOException, URISyntaxException, Interrupt @Test void testSendTemplateTextMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage2.json"); @@ -288,7 +288,7 @@ void testSendTemplateTextMessage() throws IOException, URISyntaxException, Inter @Test void testSendTemplateButtonMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage3.json"); @@ -327,7 +327,7 @@ void testSendTemplateButtonMessage() throws IOException, URISyntaxException, Int @Test void testSendTemplateButtonMessageWithDateTimeParam() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage4.json"); @@ -380,7 +380,7 @@ void testSendTemplateButtonMessageWithDateTimeParam() throws IOException, URISyn @Test void testSendTemplateButtonMessageMarketing() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage5.json"); @@ -430,7 +430,7 @@ void testSendTemplateButtonMessageMarketing() throws IOException, URISyntaxExcep @Test void testSendTemplateDocumentPdfMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage6.json"); @@ -467,7 +467,7 @@ void testSendTemplateDocumentPdfMessage() throws IOException, URISyntaxException @Test void testSendTemplateVideoMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage8.json"); @@ -500,7 +500,7 @@ void testSendTemplateVideoMessage() throws IOException, URISyntaxException, Inte @Test void testSendTemplateAuthMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage9.json"); @@ -533,7 +533,7 @@ void testSendTemplateAuthMessage() throws IOException, URISyntaxException, Inter @Test void testSendAudioMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage7.json"); @@ -556,7 +556,7 @@ void testSendAudioMessage() throws IOException, URISyntaxException, InterruptedE @Test void testSendAudioLinkMessage() throws InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = """ { @@ -591,7 +591,7 @@ void testSendAudioLinkMessage() throws InterruptedException, JSONException { @Test void testSendVideoMessage() throws InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = """ { @@ -625,7 +625,7 @@ void testSendVideoMessage() throws InterruptedException, JSONException { @Test void testSendImageMessage() throws InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = """ { @@ -657,7 +657,7 @@ void testSendImageMessage() throws InterruptedException, JSONException { @Test void testSendDocumentMessage() throws InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = """ { @@ -691,7 +691,7 @@ void testSendDocumentMessage() throws InterruptedException, JSONException { @Test void testSendStickerMessage() throws InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = """ { @@ -723,7 +723,7 @@ void testSendStickerMessage() throws InterruptedException, JSONException { @Test void testSendInteractiveMessageWithButtons() throws InterruptedException, JSONException, IOException, URISyntaxException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage11.json"); @@ -767,7 +767,7 @@ void testSendInteractiveMessageWithButtons() throws InterruptedException, JSONEx @Test void testSendInteractiveMessageWithImageHeader() throws InterruptedException, JSONException, IOException, URISyntaxException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage14.json"); @@ -810,7 +810,7 @@ void testSendInteractiveMessageWithImageHeader() throws InterruptedException, JS @Test void testSendInteractiveMessageWithVideoHeader() throws InterruptedException, JSONException, IOException, URISyntaxException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage15.json"); @@ -849,7 +849,7 @@ void testSendInteractiveMessageWithVideoHeader() throws InterruptedException, JS @Test void testSendInteractiveMessageWithDocumentHeader() throws InterruptedException, JSONException, IOException, URISyntaxException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage16.json"); @@ -893,7 +893,7 @@ void testSendInteractiveMessageWithDocumentHeader() throws InterruptedException, @Test void testSendInteractiveMessageWithList() throws InterruptedException, JSONException, IOException, URISyntaxException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage12.json"); @@ -955,7 +955,7 @@ void testSendInteractiveMessageWithList() throws InterruptedException, JSONExcep @Test void testSendReactionMessage() throws InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var emojiThumbsUp = "\uD83D\uDC4D"; var expectedJson = """ { @@ -990,7 +990,7 @@ void testSendReactionMessage() throws InterruptedException, JSONException { @Test void testSendReactionMessage2() throws InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var emojiThumbsUp = "\uD83D\uDC4D"; var expectedJson = """ { @@ -1023,7 +1023,7 @@ void testSendReactionMessage2() throws InterruptedException, JSONException { @Test void testUploadMedia() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/uploadResponse.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/uploadResponse.json")).build()); var fileContent = bytesFromResource("/starwars.png"); @@ -1039,7 +1039,7 @@ void testUploadMedia() throws IOException, URISyntaxException, InterruptedExcept @Test void testRetrieveMediaUrl() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/media.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/media.json")).build()); var response = whatsappBusinessCloudApi.retrieveMediaUrl("1227829768162607"); @@ -1057,7 +1057,7 @@ void testRetrieveMediaUrl() throws IOException, URISyntaxException, InterruptedE @Test void testDownloadMediaFile() throws InterruptedException, IOException, URISyntaxException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/starwars.png")).setResponseCode(200).addHeader("Content-Disposition", "inline;filename=starwars.png")); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/starwars.png")).addHeader("Content-Disposition", "inline;filename=starwars.png").build()); var response = whatsappBusinessCloudApi.downloadMediaFile(baseUrl + "/whatsapp_business/attachments/?mid=1228169767822607&ext=16772107977&hash=ATs5BiSbLTZzCFh73M16stmnUK2UV6NBqChXB4WWC21sw"); @@ -1073,7 +1073,7 @@ void testDownloadMediaFile() throws InterruptedException, IOException, URISyntax @Test void testDownloadMediaFileNotFound() throws InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(".").setResponseCode(404)); + mockWebServer.enqueue(new MockResponse().newBuilder().body(".").code(404).build()); var exception = Assertions.assertThrows(WhatsappApiException.class, () -> whatsappBusinessCloudApi.downloadMediaFile(baseUrl + "/whatsapp_business/attachments/?mid=1228169767822607&ext=16772107977&hash=ATs5BiSbLTZzCFh73M16stmnUK2UV6NBqChXB4WWC21sw")); @@ -1087,7 +1087,7 @@ void testDownloadMediaFileNotFound() throws InterruptedException { @Test void testDeleteMedia() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/reponse.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/reponse.json")).build()); var response = whatsappBusinessCloudApi.deleteMedia("1227829768162607"); @@ -1101,7 +1101,7 @@ void testDeleteMedia() throws IOException, URISyntaxException, InterruptedExcept @Test void testLocationMessage() throws IOException, URISyntaxException, InterruptedException, JSONException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_SEND_MESSAGE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_SEND_MESSAGE_RESPONSE).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage13.json"); @@ -1133,7 +1133,7 @@ void testMarkAsReadMessage() throws IOException, URISyntaxException, Interrupted "success": true } """; - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseBody)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(responseBody).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage17.json"); @@ -1158,7 +1158,7 @@ void testTwoStepVerification() throws IOException, URISyntaxException, Interrupt "success": true } """; - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseBody)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(responseBody).build()); var expectedJson = fromResource(EXPECTED_FOLDER + "expectedMessage18.json"); diff --git a/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java b/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java index 5161834b5..7f4d6eb0f 100644 --- a/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java +++ b/src/test/java/com/whatsapp/api/impl/WhatsappBusinessManagementApiTest.java @@ -10,15 +10,7 @@ import com.whatsapp.api.domain.phone.type.CodeMethodType; import com.whatsapp.api.domain.phone.type.NameStatusType; import com.whatsapp.api.domain.phone.type.QualityRatingType; -import com.whatsapp.api.domain.templates.BodyComponent; -import com.whatsapp.api.domain.templates.ButtonComponent; -import com.whatsapp.api.domain.templates.Example; -import com.whatsapp.api.domain.templates.FooterComponent; -import com.whatsapp.api.domain.templates.HeaderComponent; -import com.whatsapp.api.domain.templates.MessageTemplate; -import com.whatsapp.api.domain.templates.PhoneNumberButton; -import com.whatsapp.api.domain.templates.QuickReplyButton; -import com.whatsapp.api.domain.templates.UrlButton; +import com.whatsapp.api.domain.templates.*; import com.whatsapp.api.domain.templates.type.ButtonType; import com.whatsapp.api.domain.templates.type.Category; import com.whatsapp.api.domain.templates.type.HeaderFormat; @@ -61,8 +53,7 @@ void testCreateMessageTemplate() throws InterruptedException, JSONException { WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); - + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = """ { "name": "welcome_template2", @@ -127,7 +118,7 @@ void testCreateMessageTemplate2() throws IOException, URISyntaxException, Interr WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = fromResource("/expected/template/expectedTemplate1.json"); @@ -164,7 +155,7 @@ void testCreateMessageTemplate3() throws IOException, URISyntaxException, Interr WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = fromResource("/expected/template/expectedTemplate2.json"); @@ -207,7 +198,7 @@ void testCreateMessageTemplate4() throws IOException, URISyntaxException, Interr WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = fromResource("/expected/template/expectedTemplate4.json"); var template = new MessageTemplate(); @@ -247,7 +238,7 @@ void testCreateMessageTemplateUtility1() throws IOException, URISyntaxException, WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = fromResource("/expected/template/expectedTemplate6.json"); var template = new MessageTemplate(); @@ -286,7 +277,7 @@ void testCreateMessageTemplateUtility2() throws IOException, URISyntaxException, WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = fromResource("/expected/template/expectedTemplate8.json"); var template = new MessageTemplate(); @@ -323,7 +314,7 @@ void testCreateMessageTemplateAuthentication() throws IOException, URISyntaxExce WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = fromResource("/expected/template/expectedTemplate9.json"); var template = new MessageTemplate(); @@ -361,7 +352,7 @@ void testCreateMessageTemplateMarketing2() throws IOException, URISyntaxExceptio WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(DEFAULT_TEMPLATE_RESPONSE)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(DEFAULT_TEMPLATE_RESPONSE).build()); var expectedJson = fromResource("/expected/template/expectedTemplate7.json"); var template = new MessageTemplate(); @@ -403,7 +394,7 @@ void testUpdateMessageTemplate() throws IOException, URISyntaxException { WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/template.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/template.json")).build()); var template = new MessageTemplate(); @@ -434,7 +425,7 @@ void testDeleteMessageTemplate() throws IOException, URISyntaxException { WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/deleteTemplate.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/deleteTemplate.json")).build()); var resp = whatsappBusinessCloudApi.deleteMessageTemplate(WABA_ID, "welcome_template"); @@ -449,7 +440,7 @@ void testRetrieveMessageTemplate1() throws IOException, URISyntaxException, JSON var expectedJson = fromResource("/retTemplate1.json"); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(expectedJson)); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(expectedJson).build()); var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID); //TODO: review button @@ -475,7 +466,7 @@ void testRetrieveMessageTemplate2() throws IOException, URISyntaxException { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/retTemplate2.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/retTemplate2.json")).build()); var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID, 2); @@ -492,7 +483,7 @@ void testRetrieveMessageTemplate3() throws IOException, URISyntaxException { WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/retTemplate3.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/retTemplate3.json")).build()); var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID, "welcome_template3"); @@ -508,7 +499,7 @@ void testRetrieveMessageTemplate3WithLimit() throws IOException, URISyntaxExcept WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN); WhatsappBusinessManagementApi whatsappBusinessCloudApi = factory.newBusinessManagementApi(); - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/retTemplate3.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/retTemplate3.json")).build()); var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID, 1, "10"); @@ -521,7 +512,7 @@ void testRetrieveMessageTemplate3WithLimit() throws IOException, URISyntaxExcept @Test void testRetrievePhoneNumber() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/phone/phoneNumber.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/phone/phoneNumber.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -543,7 +534,7 @@ void testRetrievePhoneNumber() throws IOException, URISyntaxException, Interrupt @Test void testRetrievePhoneNumberWithSpecificFields() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/phone/phoneWithSpecificFields.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/phone/phoneWithSpecificFields.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -565,7 +556,7 @@ void testRetrievePhoneNumberWithSpecificFields() throws IOException, URISyntaxEx @Test void testRetrievePhoneNumbers() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/phone/phoneNumbersList.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/phone/phoneNumbersList.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -594,7 +585,7 @@ void testRetrievePhoneNumbers() throws IOException, URISyntaxException, Interrup @Test void testRetrievePhoneNumberNotFoundError() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(fromResource("/phone/phoneNumberNotFoundError.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(400).body(fromResource("/phone/phoneNumberNotFoundError.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -615,7 +606,7 @@ void testRetrievePhoneNumberNotFoundError() throws IOException, URISyntaxExcepti */ @Test void requestCode() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/reponse.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/reponse.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -637,7 +628,7 @@ void requestCode() throws IOException, URISyntaxException, InterruptedException */ @Test void requestCodeError() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(fromResource("/phone/requestCodeError.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(400).body(fromResource("/phone/requestCodeError.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -659,7 +650,7 @@ void requestCodeError() throws IOException, URISyntaxException, InterruptedExcep */ @Test void verifyCode() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(fromResource("/reponse.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(200).body(fromResource("/reponse.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -681,7 +672,7 @@ void verifyCode() throws IOException, URISyntaxException, InterruptedException { */ @Test void verifyCodeError() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse().setResponseCode(400).setBody(fromResource("/phone/verifyCodeError.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder().code(400).body(fromResource("/phone/verifyCodeError.json")).build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -703,9 +694,10 @@ void verifyCodeError() throws IOException, URISyntaxException, InterruptedExcept */ @Test void getWhatsappCommerceSettings() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse() - .setResponseCode(200) - .setBody(fromResource("/config/commerceSettings.json"))); + mockWebServer.enqueue(new MockResponse().newBuilder() + .code(200) + .body(fromResource("/config/commerceSettings.json")) + .build()); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN); @@ -727,9 +719,10 @@ void getWhatsappCommerceSettings() throws IOException, URISyntaxException, Inter */ @Test void updateWhatsappCommerceSettings() throws IOException, URISyntaxException, InterruptedException { - mockWebServer.enqueue(new MockResponse() - .setResponseCode(200) - .setBody(fromResource("/reponse.json")) + mockWebServer.enqueue(new MockResponse().newBuilder() + .code(200) + .body(fromResource("/reponse.json")) + .build() ); WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TestConstants.TOKEN);