Skip to content

Commit

Permalink
Merge pull request #77 from Bindambc/76-null-value-in-the-type-field-…
Browse files Browse the repository at this point in the history
…of-quickreplybutton-and-urlbutton

fix null value on field `type` in  `QuickReplyButton` and `UrlButton`
  • Loading branch information
Bindambc authored Mar 31, 2023
2 parents 6962fde + f5d9b5b commit 53efe21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class QuickReplyButton extends Button {
* Instantiates a new Quick reply button.
*/
protected QuickReplyButton() {

super(ButtonType.QUICK_REPLY);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class UrlButton extends Button {
* Instantiates a new Url button.
*/
protected UrlButton() {
super(ButtonType.URL);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.whatsapp.api.MockServerUtilsTest;
import com.whatsapp.api.TestConstants;
import com.whatsapp.api.WhatsappApiFactory;
Expand All @@ -17,6 +18,7 @@
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.type.ButtonType;
import com.whatsapp.api.domain.templates.type.Category;
import com.whatsapp.api.domain.templates.type.HeaderFormat;
import com.whatsapp.api.domain.templates.type.LanguageType;
Expand Down Expand Up @@ -450,16 +452,21 @@ void testRetrieveMessageTemplate1() throws IOException, URISyntaxException, JSON

var templates = whatsappBusinessCloudApi.retrieveTemplates(WABA_ID);
//TODO: review button
//var returnedJson = new ObjectMapper().writeValueAsString(templates);
var returnedJson = new ObjectMapper().writeValueAsString(templates);

//JSONAssert.assertEquals(expectedJson, returnedJson,JSONCompareMode.STRICT);
JSONAssert.assertEquals(expectedJson, returnedJson,JSONCompareMode.STRICT);
// data[1].components[3].buttons[0]

Assertions.assertEquals(7, templates.data().size());
Assertions.assertEquals("welcome_template3", templates.data().get(0).name());
Assertions.assertEquals("Hello {{1}}, welcome to our {{2}} test.", templates.data().get(0).components().get(1).getText());
Assertions.assertEquals("1772832833109192", templates.data().get(6).id());

var buttonComponent = (ButtonComponent) templates.data().get(1).components().get(3);

Assertions.assertEquals(ButtonType.QUICK_REPLY,buttonComponent.getButtons().get(0).getType());


}

@Test
Expand Down

0 comments on commit 53efe21

Please sign in to comment.