@Test void testSerializationStructure() throws Exception { when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("info:event/12345")); when(mockEvent.getAgents()).thenReturn(singleton(rdf.createIRI("info:user/test"))); when(mockEvent.getObject()).thenReturn(of(rdf.createIRI("trellis:data/resource"))); when(mockEvent.getObjectTypes()).thenReturn(singleton(Container)); when(mockEvent.getInbox()).thenReturn(of(rdf.createIRI("info:ldn/inbox"))); when(mockEvent.getCreated()).thenReturn(time); when(mockEvent.getTypes()).thenReturn(asList(Create, Activity)); final String json = svc.serialize(mockEvent); final Jsonb jsonb = JsonbBuilder.create(); @SuppressWarnings("unchecked") final Map<String, Object> map = jsonb.fromJson(json, Map.class); assertTrue(map.containsKey("@context"), "@context property not in JSON structure!"); assertTrue(map.containsKey("id"), "id property not in JSON structure!"); assertTrue(map.containsKey("type"), "type property not in JSON structure!"); assertTrue(map.containsKey("inbox"), "inbox property not in JSON structure!"); assertTrue(map.containsKey("actor"), "actor property not in JSON structure!"); assertTrue(map.containsKey("object"), "object property not in JSON structure!"); assertTrue(map.containsKey("published"), "published property not in JSON structure!"); final List<?> types = (List<?>) map.get("type"); assertTrue(types.contains("Create"), "as:Create not in type list!"); assertTrue(types.contains(Activity.getIRIString()), "prov:Activity not in type list!"); assertTrue(AS.getNamespace().contains((String) map.get("@context")), "AS namespace not in @context!"); final List<?> actor = (List<?>) map.get("actor"); assertTrue(actor.contains("info:user/test"), "actor property has incorrect value!"); assertEquals("info:event/12345", map.get("id"), "id property has incorrect value!"); assertEquals("info:ldn/inbox", map.get("inbox"), "inbox property has incorrect value!"); assertEquals(time.toString(), map.get("published"), "published property has incorrect value!"); }
@Override public String serialize(final Event event) { return jsonb.toJson(ActivityStreamMessage.from(event)); }
DefaultEventSerializationService implements EventSerializationService { @Override public String serialize(final Event event) { return jsonb.toJson(ActivityStreamMessage.from(event)); } }
DefaultEventSerializationService implements EventSerializationService { @Override public String serialize(final Event event) { return jsonb.toJson(ActivityStreamMessage.from(event)); }  }
DefaultEventSerializationService implements EventSerializationService { @Override public String serialize(final Event event) { return jsonb.toJson(ActivityStreamMessage.from(event)); }  @Override String serialize(final Event event); }
DefaultEventSerializationService implements EventSerializationService { @Override public String serialize(final Event event) { return jsonb.toJson(ActivityStreamMessage.from(event)); }  @Override String serialize(final Event event);  }