コード例 #1
0
 @Test
 public void testSimpleJsonToNotification() throws IOException {
   String expectedContents =
       "Notification [event=null, filterId=e3c045ec-8028-48ce-9373-93e5b01c690c, filterName=Pester Michael about Critical events, notificationId=4ba705f6-690c-4877-b041-791b84e1e032]";
   String s = readFile(NOTIFICATION_BASIC_JSON, Charset.defaultCharset());
   ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally
   Notification notification = mapper.readValue(s, Notification.class);
   System.out.println("notification: " + notification);
   assertEquals("Notification output incorrect", expectedContents, notification.toString());
 }
コード例 #2
0
  @Test
  public void testUnMarshallingJsonSimple() throws InterruptedException, IOException {
    out.setExpectedMessageCount(1);
    String s = readFile(NOTIFICATION_BASIC_JSON, Charset.defaultCharset());
    in.sendBody(s);
    out.await(5, TimeUnit.SECONDS);
    out.assertIsSatisfied();
    List<Exchange> exchanges = out.getExchanges();

    for (Exchange exchange : exchanges) {
      Message message = exchange.getIn();
      Notification notif = message.getBody(Notification.class);
      assertEquals(
          "filterId does not match", "e3c045ec-8028-48ce-9373-93e5b01c690c", notif.getFilterId());
      assertEquals(
          "filterName does not match",
          "Pester Michael about Critical events",
          notif.getFilterName());
      assertEquals(
          "notificationId does not match",
          "4ba705f6-690c-4877-b041-791b84e1e032",
          notif.getNotificationId());
    }
  }