@@ -1077,6 +1077,44 @@ public void testCreateWhatsAppTemplate() throws UnauthorizedException, GeneralEx
10771077 assertEquals (response .getComponents ().get (i ).getText (), templateResponse .getComponents ().get (i ).getText ());
10781078 }
10791079 }
1080+ @ Test
1081+ public void testUpdateWhatsAppTemplate () throws UnauthorizedException , GeneralException {
1082+ final TemplateResponse templateResponse = TestUtil .createWhatsAppTemplateResponse ("sample_template_name" , "ko" );
1083+ final Template template = TestUtil .createWhatsAppTemplate ("sample_template_name" , "ko" );
1084+
1085+ MessageBirdService messageBirdServiceMock = mock (MessageBirdService .class );
1086+ MessageBirdClient messageBirdClientInjectMock = new MessageBirdClient (messageBirdServiceMock );
1087+
1088+ String url = String .format (
1089+ "%s%s%s/%s/%s" ,
1090+ INTEGRATIONS_BASE_URL_V2 ,
1091+ INTEGRATIONS_WHATSAPP_PATH ,
1092+ TEMPLATES_PATH ,
1093+ "sample_template_name" ,
1094+ "ko"
1095+ );
1096+
1097+ when (messageBirdServiceMock .sendPayLoad ("PUT" ,url , template , TemplateResponse .class ))
1098+ .thenReturn (templateResponse );
1099+
1100+ final TemplateResponse response = messageBirdClientInjectMock .updateWhatsAppTemplate (template ,"sample_template_name" ,"ko" );
1101+ verify (messageBirdServiceMock , times (1 )).sendPayLoad ("PUT" ,url , template , TemplateResponse .class );
1102+ assertNotNull (response );
1103+ assertEquals (response .getName (), templateResponse .getName ());
1104+ assertEquals (response .getLanguage (), templateResponse .getLanguage ());
1105+ assertEquals (response .getCategory (), templateResponse .getCategory ());
1106+ assertEquals (response .getStatus (), templateResponse .getStatus ());
1107+ assertEquals (response .getWabaID (), templateResponse .getWabaID ());
1108+ assertEquals (response .getCreatedAt (), templateResponse .getCreatedAt ());
1109+ assertEquals (response .getUpdatedAt (), templateResponse .getUpdatedAt ());
1110+
1111+ /* verify components */
1112+ for (int i = 0 ; i < response .getComponents ().size (); i ++) {
1113+ assertEquals (response .getComponents ().get (i ).getType (), templateResponse .getComponents ().get (i ).getType ());
1114+ assertEquals (response .getComponents ().get (i ).getFormat (), templateResponse .getComponents ().get (i ).getFormat ());
1115+ assertEquals (response .getComponents ().get (i ).getText (), templateResponse .getComponents ().get (i ).getText ());
1116+ }
1117+ }
10801118
10811119 @ Test
10821120 public void testListWhatsAppTemplates () throws UnauthorizedException , GeneralException {
0 commit comments