@Test public void testSerialize_NoUserData() throws Exception { String myName = testName.getMethodName(); Notification n = new Notification(myName, myName, 1, myName); SimpleNotificationSerializer serializer = new SimpleNotificationSerializer(); AdaptrisMessage msg = serializer.serialize(n, AdaptrisMessageFactory.getDefaultInstance().newMessage()); try (InputStream in = msg.getInputStream()) { Properties p = new Properties(); p.load(in); assertEquals(myName, p.getProperty("Source")); assertEquals(myName, p.getProperty("Type")); assertEquals(myName, p.getProperty("Message")); assertEquals("1", p.getProperty("SequenceNumber")); assertNotNull(p.getProperty("Timestamp")); assertNull(msg.getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA)); } }
public AdaptrisMessage serialize(Notification n, AdaptrisMessage msg) throws CoreException, IOException { Properties p = new Properties(); for (NotificationElement e : NotificationElement.values()) { e.apply(n, p); } try (OutputStream out = msg.getOutputStream()) { p.store(out, ""); } if (n.getUserData() != null) { msg.getObjectHeaders().put(OBJ_METADATA_USERDATA, n.getUserData()); } return msg; }
SimpleNotificationSerializer implements NotificationSerializer { public AdaptrisMessage serialize(Notification n, AdaptrisMessage msg) throws CoreException, IOException { Properties p = new Properties(); for (NotificationElement e : NotificationElement.values()) { e.apply(n, p); } try (OutputStream out = msg.getOutputStream()) { p.store(out, ""); } if (n.getUserData() != null) { msg.getObjectHeaders().put(OBJ_METADATA_USERDATA, n.getUserData()); } return msg; } }
SimpleNotificationSerializer implements NotificationSerializer { public AdaptrisMessage serialize(Notification n, AdaptrisMessage msg) throws CoreException, IOException { Properties p = new Properties(); for (NotificationElement e : NotificationElement.values()) { e.apply(n, p); } try (OutputStream out = msg.getOutputStream()) { p.store(out, ""); } if (n.getUserData() != null) { msg.getObjectHeaders().put(OBJ_METADATA_USERDATA, n.getUserData()); } return msg; }  }
SimpleNotificationSerializer implements NotificationSerializer { public AdaptrisMessage serialize(Notification n, AdaptrisMessage msg) throws CoreException, IOException { Properties p = new Properties(); for (NotificationElement e : NotificationElement.values()) { e.apply(n, p); } try (OutputStream out = msg.getOutputStream()) { p.store(out, ""); } if (n.getUserData() != null) { msg.getObjectHeaders().put(OBJ_METADATA_USERDATA, n.getUserData()); } return msg; }  AdaptrisMessage serialize(Notification n, AdaptrisMessage msg); }
SimpleNotificationSerializer implements NotificationSerializer { public AdaptrisMessage serialize(Notification n, AdaptrisMessage msg) throws CoreException, IOException { Properties p = new Properties(); for (NotificationElement e : NotificationElement.values()) { e.apply(n, p); } try (OutputStream out = msg.getOutputStream()) { p.store(out, ""); } if (n.getUserData() != null) { msg.getObjectHeaders().put(OBJ_METADATA_USERDATA, n.getUserData()); } return msg; }  AdaptrisMessage serialize(Notification n, AdaptrisMessage msg);  }