@@ -22,6 +22,7 @@ public class ConversationMessagesTest {
22
22
private static final String JSON_CONVERSATION_MESSAGE_LOCATION = "{\" id\" : \" mesid\" ,\" conversationId\" : \" convid\" ,\" channelId\" : \" chanid\" ,\" status\" : \" received\" ,\" type\" : \" location\" ,\" direction\" : \" received\" ,\" content\" : {\" location\" : { \" latitude\" : 52.344263, \" longitude\" : 4.911627 } },\" createdDatetime\" : \" 2018-08-29T11:49:16Z\" ,\" updatedDatetime\" : \" 2018-08-29T11:49:16Z\" }" ;
23
23
private static final String JSON_CONVERSATION_MESSAGE_TEXT = "{\" id\" : \" mesid\" ,\" conversationId\" : \" convid\" ,\" channelId\" : \" chanid\" ,\" status\" : \" received\" ,\" type\" : \" text\" ,\" direction\" : \" received\" ,\" content\" : {\" text\" : \" Hello\" },\" createdDatetime\" : \" 2018-08-29T11:49:16Z\" ,\" updatedDatetime\" : \" 2018-08-29T11:49:16Z\" }" ;
24
24
private static final String JSON_CONVERSATION_MESSAGE_VIDEO = "{\" id\" : \" mesid\" ,\" conversationId\" : \" convid\" ,\" channelId\" : \" chanid\" ,\" status\" : \" received\" ,\" type\" : \" video\" ,\" direction\" : \" received\" ,\" content\" : {\" video\" : { \" url\" : \" https://example.com/video.mp4\" } },\" createdDatetime\" : \" 2018-08-29T11:49:16Z\" ,\" updatedDatetime\" : \" 2018-08-29T11:49:16Z\" }" ;
25
+ private static final String JSON_CONVERSATION_SEND_MESSAGE_RESPONSE = "{\" id\" :\" mesid\" ,\" status\" :\" accepted\" ,\" fallback\" :{\" id\" :\" mesid\" }}" ;
25
26
26
27
/**
27
28
* Epsilon to use when checking two latitudes or longitudes for equality.
@@ -66,6 +67,31 @@ public void testSendConversationMessage() throws GeneralException, UnauthorizedE
66
67
assertEquals (ConversationContentType .VIDEO , conversationMessage .getType ());
67
68
}
68
69
70
+ @ Test
71
+ public void testSendMessage () throws GeneralException , UnauthorizedException {
72
+ ConversationContent conversationContent = new ConversationContent ();
73
+ conversationContent .setText ("test" );
74
+
75
+ ConversationSendRequest sendRequest = new ConversationSendRequest ();
76
+ sendRequest .setFrom ("aChannelIdentifier" );
77
+ sendRequest .setType (ConversationContentType .TEXT );
78
+ sendRequest .setContent (conversationContent );
79
+ sendRequest .setReportUrl ("https://example.com/reportUrl" );
80
+
81
+ MessageBirdService messageBirdService = SpyService
82
+ .expects ("POST" , "send" , sendRequest )
83
+ .withConversationsAPIBaseURL ()
84
+ .andReturns (new APIResponse (JSON_CONVERSATION_SEND_MESSAGE_RESPONSE ));
85
+ MessageBirdClient messageBirdClient = new MessageBirdClient (messageBirdService );
86
+
87
+ ConversationSendResponse conversationMessage
88
+ = messageBirdClient .sendMessage (sendRequest );
89
+
90
+ assertEquals ("mesid" , conversationMessage .getId ());
91
+ assertEquals ("accepted" , conversationMessage .getStatus ());
92
+ assertEquals ("mesid" , conversationMessage .getFallback ().getId ());
93
+ }
94
+
69
95
@ Test
70
96
public void testViewConversationMessageAudio () throws GeneralException , NotFoundException , UnauthorizedException {
71
97
MessageBirdService messageBirdService = SpyService
0 commit comments