@Test public void pushNotification_withBadgeCount() { masterKeyMockServer.expect(requestTo("https: .andExpect(header("Content-Type", "application/json")) .andExpect(body(readCompactedJsonResource(jsonResource("data/push-withbadgecount")))) .andExpect(method(POST)) .andRespond(withResponse("", responseHeaders, HttpStatus.OK, "Okay")); PushResponse response = urbanAirship.pushOperations().pushNotification(Notification.builder("Hey!").deviceTokens(DEVICE_TOKEN).badge(10).build()); assertNull(response); masterKeyMockServer.verify(); }
public PushResponse pushNotification(Notification notification) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<Notification> requestEntity = new HttpEntity<Notification>(notification, headers); if (notification.getScheduleFor() != null && !notification.getScheduleFor().isEmpty()) { return masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, PushResponse.class).getBody(); } masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, String.class); return null; }
PushTemplate implements PushOperations { public PushResponse pushNotification(Notification notification) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<Notification> requestEntity = new HttpEntity<Notification>(notification, headers); if (notification.getScheduleFor() != null && !notification.getScheduleFor().isEmpty()) { return masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, PushResponse.class).getBody(); } masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, String.class); return null; } }
PushTemplate implements PushOperations { public PushResponse pushNotification(Notification notification) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<Notification> requestEntity = new HttpEntity<Notification>(notification, headers); if (notification.getScheduleFor() != null && !notification.getScheduleFor().isEmpty()) { return masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, PushResponse.class).getBody(); } masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, String.class); return null; } PushTemplate(RestOperations masterKeyRestOperations); }
PushTemplate implements PushOperations { public PushResponse pushNotification(Notification notification) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<Notification> requestEntity = new HttpEntity<Notification>(notification, headers); if (notification.getScheduleFor() != null && !notification.getScheduleFor().isEmpty()) { return masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, PushResponse.class).getBody(); } masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, String.class); return null; } PushTemplate(RestOperations masterKeyRestOperations); PushResponse pushNotification(Notification notification); void pushNotifications(List<Notification> notifications); void sendBroadcast(Broadcast broadcast); List<PushStatistics> getStatistics(Date start, Date end); }
PushTemplate implements PushOperations { public PushResponse pushNotification(Notification notification) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<Notification> requestEntity = new HttpEntity<Notification>(notification, headers); if (notification.getScheduleFor() != null && !notification.getScheduleFor().isEmpty()) { return masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, PushResponse.class).getBody(); } masterKeyRestOperations.exchange(PUSH_URL, HttpMethod.POST, requestEntity, String.class); return null; } PushTemplate(RestOperations masterKeyRestOperations); PushResponse pushNotification(Notification notification); void pushNotifications(List<Notification> notifications); void sendBroadcast(Broadcast broadcast); List<PushStatistics> getStatistics(Date start, Date end);  }