use of org.infobip.mobile.messaging.api.messages.SyncMessagesResponse in project mobile-messaging-sdk-android by infobip.
the class MobileApiMessagesTest method sync_messages_success.
@Test
public void sync_messages_success() {
String serverResponse = "{\n" + " \"payloads\": [\n" + " {\n" + " \"gcm.notification.messageId\": \"test-message-id\",\n" + " \"gcm.notification.title\": \"this is title\",\n" + " \"gcm.notification.body\": \"body\",\n" + " \"gcm.notification.sound\": \"true\",\n" + " \"gcm.notification.vibrate\": \"true\",\n" + " \"gcm.notification.silent\": \"true\",\n" + " \"gcm.notification.category\": \"UNKNOWN\"\n" + " }\n" + " ]\n" + "}";
debugServer.respondWith(NanoHTTPD.Response.Status.OK, serverResponse);
String[] mIDs = new String[1];
mIDs[0] = "test-message-id";
String[] drIDs = new String[1];
drIDs[0] = "test-message-id";
SyncMessagesBody syncMessagesBody = SyncMessagesBody.make(mIDs, drIDs);
SyncMessagesResponse syncMessagesResponse = mobileApiMessages.sync(syncMessagesBody);
// inspect http context
assertThat(debugServer.getUri()).isEqualTo("/mobile/5/messages/");
assertThat(debugServer.getRequestCount()).isEqualTo(1);
assertThat(debugServer.getRequestMethod()).isEqualTo(NanoHTTPD.Method.POST);
assertThat(debugServer.getQueryParametersCount()).isEqualTo(1);
assertThat(debugServer.getBody()).isNotEqualTo(null);
// inspect response
assertEquals(1, syncMessagesResponse.getPayloads().size());
MessageResponse messageResponse = syncMessagesResponse.getPayloads().get(0);
assertEquals("test-message-id", messageResponse.getMessageId());
assertEquals("this is title", messageResponse.getTitle());
assertEquals("body", messageResponse.getBody());
assertEquals("true", messageResponse.getSound());
assertEquals("true", messageResponse.getVibrate());
assertEquals("true", messageResponse.getSilent());
assertEquals("UNKNOWN", messageResponse.getCategory());
}
Aggregations