Subscription { public void setId(String id) { this.id = id; } Subscription();  Subscription(String id, SubjectSubscription subject, Notification notification, Instant expires, Status status); String getId(); void setId(String id); SubjectSubscription getSubject(); void setSubject(SubjectSubscription subject); Notification getNotification(); void setNotification(Notification notification); Status getStatus(); void setStatus(Status status); Instant getExpires(); void setExpires(Instant expires);  }
@Test public void serializationSubscriptionTest() throws JsonProcessingException, MalformedURLException { ObjectWriter writer = Utils.objectMapper.writer(new DefaultPrettyPrinter()); SubjectEntity subjectEntity = new SubjectEntity(); subjectEntity.setId(Optional.of("Bcn_Welt")); subjectEntity.setType(Optional.of("Room")); Condition condition = new Condition(); condition.setAttributes(Collections.singletonList("temperature")); condition.setExpression("q", "temperature>40"); SubjectSubscription subjectSubscription = new SubjectSubscription(Collections.singletonList(subjectEntity), condition); List<String> attributes = new ArrayList<>(); attributes.add("temperature"); attributes.add("humidity"); Notification notification = new Notification(attributes, new URL("http: notification.setThrottling(Optional.of(new Long(5))); notification.setTimesSent(12); notification.setLastNotification(Instant.parse("2015-10-05T16:00:00.10Z")); notification.setHeader("X-MyHeader", "foo"); notification.setQuery("authToken", "bar"); notification.setAttrsFormat(Optional.of(Notification.Format.keyValues)); String json = writer.writeValueAsString(new Subscription("abcdefg", subjectSubscription, notification, Instant.parse("2016-04-05T14:00:00.20Z"), Subscription.Status.active)); assertEquals(jsonString, json); }