use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.NotificationCreate in project event-notifications-java-admin-sdk by IBM.
the class EventNotificationsTest method testSendNotificationsWOptions.
// Test the sendNotifications operation with a valid options model parameter
@Test
public void testSendNotificationsWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"notification_id\": \"notificationId\"}";
String sendNotificationsPath = "/v1/instances/testString/notifications";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(202).setBody(mockResponseBody));
// Construct an instance of the NotificationCreate model
NotificationCreate notificationCreateModel = new NotificationCreate.Builder().data(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).ibmenseverity("testString").ibmenfcmbody("testString").ibmenapnsbody("testString").ibmensafaribody("testString").ibmenpushto("{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}").ibmenapnsheaders("testString").ibmendefaultshort("testString").ibmendefaultlong("testString").ibmenchromebody("testString").ibmenfirefoxbody("testString").ibmenchromeheaders("testString").ibmenfirefoxheaders("testString").ibmensourceid("testString").datacontenttype("application/json").subject("testString").id("testString").source("testString").type("testString").specversion("1.0").time("testString").add("foo", "testString").build();
// Construct an instance of the SendNotificationsOptions model
SendNotificationsOptions sendNotificationsOptionsModel = new SendNotificationsOptions.Builder().instanceId("testString").body(notificationCreateModel).ceIbmenseverity("testString").ceIbmendefaultshort("testString").ceIbmendefaultlong("testString").ceIbmenfcmbody("testString").ceIbmenapnsbody("testString").ceIbmensafaribody("testString").ceIbmenpushto("{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}").ceIbmenapnsheaders("testString").ceIbmenchromebody("testString").ceIbmenfirefoxbody("testString").ceIbmenchromeheaders("testString").ceIbmenfirefoxheaders("testString").ceIbmensourceid("testString").ceId("testString").ceSource("testString").ceType("testString").ceSpecversion("1.0").ceTime("testString").build();
// Invoke sendNotifications() with a valid options model and verify the result
Response<NotificationResponse> response = eventNotificationsService.sendNotifications(sendNotificationsOptionsModel).execute();
assertNotNull(response);
NotificationResponse responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, sendNotificationsPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.NotificationCreate in project event-notifications-java-admin-sdk by IBM.
the class SendBulkNotificationsOptionsTest method testSendBulkNotificationsOptions.
@Test
public void testSendBulkNotificationsOptions() throws Throwable {
NotificationCreate notificationCreateModel = new NotificationCreate.Builder().data(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).ibmenseverity("testString").ibmenfcmbody("testString").ibmenapnsbody("testString").ibmensafaribody("testString").ibmenpushto("{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}").ibmenapnsheaders("testString").ibmendefaultshort("testString").ibmendefaultlong("testString").ibmenchromebody("testString").ibmenfirefoxbody("testString").ibmenchromeheaders("testString").ibmenfirefoxheaders("testString").ibmensourceid("testString").datacontenttype("application/json").subject("testString").id("testString").source("testString").type("testString").specversion("1.0").time("testString").add("foo", "testString").build();
assertEquals(notificationCreateModel.getData(), new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
});
assertEquals(notificationCreateModel.getIbmenseverity(), "testString");
assertEquals(notificationCreateModel.getIbmenfcmbody(), "testString");
assertEquals(notificationCreateModel.getIbmenapnsbody(), "testString");
assertEquals(notificationCreateModel.getIbmensafaribody(), "testString");
assertEquals(notificationCreateModel.getIbmenpushto(), "{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}");
assertEquals(notificationCreateModel.getIbmenapnsheaders(), "testString");
assertEquals(notificationCreateModel.getIbmendefaultshort(), "testString");
assertEquals(notificationCreateModel.getIbmendefaultlong(), "testString");
assertEquals(notificationCreateModel.getIbmenchromebody(), "testString");
assertEquals(notificationCreateModel.getIbmenfirefoxbody(), "testString");
assertEquals(notificationCreateModel.getIbmenchromeheaders(), "testString");
assertEquals(notificationCreateModel.getIbmenfirefoxheaders(), "testString");
assertEquals(notificationCreateModel.getIbmensourceid(), "testString");
assertEquals(notificationCreateModel.getDatacontenttype(), "application/json");
assertEquals(notificationCreateModel.getSubject(), "testString");
assertEquals(notificationCreateModel.getId(), "testString");
assertEquals(notificationCreateModel.getSource(), "testString");
assertEquals(notificationCreateModel.getType(), "testString");
assertEquals(notificationCreateModel.getSpecversion(), "1.0");
assertEquals(notificationCreateModel.getTime(), "testString");
assertEquals(notificationCreateModel.get("foo"), "testString");
SendBulkNotificationsOptions sendBulkNotificationsOptionsModel = new SendBulkNotificationsOptions.Builder().instanceId("testString").bulkMessages(new java.util.ArrayList<NotificationCreate>(java.util.Arrays.asList(notificationCreateModel))).build();
assertEquals(sendBulkNotificationsOptionsModel.instanceId(), "testString");
assertEquals(sendBulkNotificationsOptionsModel.bulkMessages(), new java.util.ArrayList<NotificationCreate>(java.util.Arrays.asList(notificationCreateModel)));
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.NotificationCreate in project event-notifications-java-admin-sdk by IBM.
the class EventNotificationsTest method testSendBulkNotificationsWOptions.
// Test the sendBulkNotifications operation with a valid options model parameter
@Test
public void testSendBulkNotificationsWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"bulk_notification_id\": \"bulkNotificationId\", \"bulk_messages\": [\"anyValue\"]}";
String sendBulkNotificationsPath = "/v1/instances/testString/notifications/bulk";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(202).setBody(mockResponseBody));
// Construct an instance of the NotificationCreate model
NotificationCreate notificationCreateModel = new NotificationCreate.Builder().data(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).ibmenseverity("testString").ibmenfcmbody("testString").ibmenapnsbody("testString").ibmensafaribody("testString").ibmenpushto("{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}").ibmenapnsheaders("testString").ibmendefaultshort("testString").ibmendefaultlong("testString").ibmenchromebody("testString").ibmenfirefoxbody("testString").ibmenchromeheaders("testString").ibmenfirefoxheaders("testString").ibmensourceid("testString").datacontenttype("application/json").subject("testString").id("testString").source("testString").type("testString").specversion("1.0").time("testString").add("foo", "testString").build();
// Construct an instance of the SendBulkNotificationsOptions model
SendBulkNotificationsOptions sendBulkNotificationsOptionsModel = new SendBulkNotificationsOptions.Builder().instanceId("testString").bulkMessages(new java.util.ArrayList<NotificationCreate>(java.util.Arrays.asList(notificationCreateModel))).build();
// Invoke sendBulkNotifications() with a valid options model and verify the result
Response<BulkNotificationResponse> response = eventNotificationsService.sendBulkNotifications(sendBulkNotificationsOptionsModel).execute();
assertNotNull(response);
BulkNotificationResponse responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, sendBulkNotificationsPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.NotificationCreate in project event-notifications-java-admin-sdk by IBM.
the class NotificationCreateTest method testNotificationCreate.
@Test
public void testNotificationCreate() throws Throwable {
NotificationCreate notificationCreateModel = new NotificationCreate.Builder().data(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).ibmenseverity("testString").ibmenfcmbody("testString").ibmenapnsbody("testString").ibmensafaribody("testString").ibmenpushto("{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}").ibmenapnsheaders("testString").ibmendefaultshort("testString").ibmendefaultlong("testString").ibmenchromebody("testString").ibmenfirefoxbody("testString").ibmenchromeheaders("testString").ibmenfirefoxheaders("testString").ibmensourceid("testString").datacontenttype("application/json").subject("testString").id("testString").source("testString").type("testString").specversion("1.0").time("testString").add("foo", "testString").build();
assertEquals(notificationCreateModel.getData(), new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
});
assertEquals(notificationCreateModel.getIbmenseverity(), "testString");
assertEquals(notificationCreateModel.getIbmenfcmbody(), "testString");
assertEquals(notificationCreateModel.getIbmenapnsbody(), "testString");
assertEquals(notificationCreateModel.getIbmensafaribody(), "testString");
assertEquals(notificationCreateModel.getIbmenpushto(), "{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}");
assertEquals(notificationCreateModel.getIbmenapnsheaders(), "testString");
assertEquals(notificationCreateModel.getIbmendefaultshort(), "testString");
assertEquals(notificationCreateModel.getIbmendefaultlong(), "testString");
assertEquals(notificationCreateModel.getIbmenchromebody(), "testString");
assertEquals(notificationCreateModel.getIbmenfirefoxbody(), "testString");
assertEquals(notificationCreateModel.getIbmenchromeheaders(), "testString");
assertEquals(notificationCreateModel.getIbmenfirefoxheaders(), "testString");
assertEquals(notificationCreateModel.getIbmensourceid(), "testString");
assertEquals(notificationCreateModel.getDatacontenttype(), "application/json");
assertEquals(notificationCreateModel.getSubject(), "testString");
assertEquals(notificationCreateModel.getId(), "testString");
assertEquals(notificationCreateModel.getSource(), "testString");
assertEquals(notificationCreateModel.getType(), "testString");
assertEquals(notificationCreateModel.getSpecversion(), "1.0");
assertEquals(notificationCreateModel.getTime(), "testString");
assertEquals(notificationCreateModel.get("foo"), "testString");
String json = TestUtilities.serialize(notificationCreateModel);
NotificationCreate notificationCreateModelNew = TestUtilities.deserialize(json, NotificationCreate.class);
assertTrue(notificationCreateModelNew instanceof NotificationCreate);
assertEquals(notificationCreateModelNew.getIbmenseverity(), "testString");
assertEquals(notificationCreateModelNew.getIbmenfcmbody(), "testString");
assertEquals(notificationCreateModelNew.getIbmenapnsbody(), "testString");
assertEquals(notificationCreateModelNew.getIbmensafaribody(), "testString");
assertEquals(notificationCreateModelNew.getIbmenpushto(), "{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}");
assertEquals(notificationCreateModelNew.getIbmenapnsheaders(), "testString");
assertEquals(notificationCreateModelNew.getIbmendefaultshort(), "testString");
assertEquals(notificationCreateModelNew.getIbmendefaultlong(), "testString");
assertEquals(notificationCreateModelNew.getIbmenchromebody(), "testString");
assertEquals(notificationCreateModelNew.getIbmenfirefoxbody(), "testString");
assertEquals(notificationCreateModelNew.getIbmenchromeheaders(), "testString");
assertEquals(notificationCreateModelNew.getIbmenfirefoxheaders(), "testString");
assertEquals(notificationCreateModelNew.getIbmensourceid(), "testString");
assertEquals(notificationCreateModelNew.getDatacontenttype(), "application/json");
assertEquals(notificationCreateModelNew.getSubject(), "testString");
assertEquals(notificationCreateModelNew.getId(), "testString");
assertEquals(notificationCreateModelNew.getSource(), "testString");
assertEquals(notificationCreateModelNew.getType(), "testString");
assertEquals(notificationCreateModelNew.getSpecversion(), "1.0");
assertEquals(notificationCreateModelNew.getTime(), "testString");
assertEquals(notificationCreateModelNew.get("foo"), "testString");
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.NotificationCreate in project event-notifications-java-admin-sdk by IBM.
the class SendNotificationsOptionsTest method testSendNotificationsOptions.
@Test
public void testSendNotificationsOptions() throws Throwable {
NotificationCreate notificationCreateModel = new NotificationCreate.Builder().data(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).ibmenseverity("testString").ibmenfcmbody("testString").ibmenapnsbody("testString").ibmensafaribody("testString").ibmenpushto("{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}").ibmenapnsheaders("testString").ibmendefaultshort("testString").ibmendefaultlong("testString").ibmenchromebody("testString").ibmenfirefoxbody("testString").ibmenchromeheaders("testString").ibmenfirefoxheaders("testString").ibmensourceid("testString").datacontenttype("application/json").subject("testString").id("testString").source("testString").type("testString").specversion("1.0").time("testString").add("foo", "testString").build();
assertEquals(notificationCreateModel.getData(), new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
});
assertEquals(notificationCreateModel.getIbmenseverity(), "testString");
assertEquals(notificationCreateModel.getIbmenfcmbody(), "testString");
assertEquals(notificationCreateModel.getIbmenapnsbody(), "testString");
assertEquals(notificationCreateModel.getIbmensafaribody(), "testString");
assertEquals(notificationCreateModel.getIbmenpushto(), "{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}");
assertEquals(notificationCreateModel.getIbmenapnsheaders(), "testString");
assertEquals(notificationCreateModel.getIbmendefaultshort(), "testString");
assertEquals(notificationCreateModel.getIbmendefaultlong(), "testString");
assertEquals(notificationCreateModel.getIbmenchromebody(), "testString");
assertEquals(notificationCreateModel.getIbmenfirefoxbody(), "testString");
assertEquals(notificationCreateModel.getIbmenchromeheaders(), "testString");
assertEquals(notificationCreateModel.getIbmenfirefoxheaders(), "testString");
assertEquals(notificationCreateModel.getIbmensourceid(), "testString");
assertEquals(notificationCreateModel.getDatacontenttype(), "application/json");
assertEquals(notificationCreateModel.getSubject(), "testString");
assertEquals(notificationCreateModel.getId(), "testString");
assertEquals(notificationCreateModel.getSource(), "testString");
assertEquals(notificationCreateModel.getType(), "testString");
assertEquals(notificationCreateModel.getSpecversion(), "1.0");
assertEquals(notificationCreateModel.getTime(), "testString");
assertEquals(notificationCreateModel.get("foo"), "testString");
SendNotificationsOptions sendNotificationsOptionsModel = new SendNotificationsOptions.Builder().instanceId("testString").body(notificationCreateModel).ceIbmenseverity("testString").ceIbmendefaultshort("testString").ceIbmendefaultlong("testString").ceIbmenfcmbody("testString").ceIbmenapnsbody("testString").ceIbmensafaribody("testString").ceIbmenpushto("{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}").ceIbmenapnsheaders("testString").ceIbmenchromebody("testString").ceIbmenfirefoxbody("testString").ceIbmenchromeheaders("testString").ceIbmenfirefoxheaders("testString").ceIbmensourceid("testString").ceId("testString").ceSource("testString").ceType("testString").ceSpecversion("1.0").ceTime("testString").build();
assertEquals(sendNotificationsOptionsModel.instanceId(), "testString");
assertEquals(sendNotificationsOptionsModel.body(), notificationCreateModel);
assertEquals(sendNotificationsOptionsModel.ceIbmenseverity(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmendefaultshort(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmendefaultlong(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmenfcmbody(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmenapnsbody(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmensafaribody(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmenpushto(), "{\"fcm_devices\":[\"9c75975a-37d0-3898-905d-3b5ee0d7c172\",\"C9CACDF5-6EBF-49E1-AD60-E25BA23E954C\"],\"apns_devices\":[\"3423-37d0-3898-905d-42342\",\"432423-6EBF-49E1-AD60-4234\"],\"user_ids\":[\"user-1\",\"user-2\"],\"tags\":[\"tag-1\",\"tag-2\"],\"platforms\":[\"push_android\",\"push_ios\",\"push_chrome\",\"push_firefox\"]}");
assertEquals(sendNotificationsOptionsModel.ceIbmenapnsheaders(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmenchromebody(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmenfirefoxbody(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmenchromeheaders(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmenfirefoxheaders(), "testString");
assertEquals(sendNotificationsOptionsModel.ceIbmensourceid(), "testString");
assertEquals(sendNotificationsOptionsModel.ceId(), "testString");
assertEquals(sendNotificationsOptionsModel.ceSource(), "testString");
assertEquals(sendNotificationsOptionsModel.ceType(), "testString");
assertEquals(sendNotificationsOptionsModel.ceSpecversion(), "1.0");
assertEquals(sendNotificationsOptionsModel.ceTime(), "testString");
}
Aggregations