@Test public void testFullDeserialize() throws Exception { String json = CharStreams.toString(new InputStreamReader(getClass().getResourceAsStream("/sample-event.json"))); EventSourceDescriptor source = new EventSourceDescriptor() .setEnvironment(new EnvironmentDescriptor() .setAccountId("000011112222") .setRegion("ap-northeast-1") .setInstanceId("i-0123456789abcdef")) .setProduct(new ProductDescriptor() .setName("foobar") .setRole("bazqux") .setVersion("1.23")); SWEvent expected = new SWEvent(source, 1460622200299L, "test_event") .setAuthentication(new AuthenticationDescriptor() .setClientId("test.client01") .setUsername("test.user01")) .setHttpRequest(new HttpRequestDescriptor() .setRequestId("57e4e60b-fd57-402f-a5f2-bc984fa63c16") .setUri("http: .setMethod("GET") .setRemoteAddr("203.0.113.3") .setRemoteHost("203.0.113.3") .setSessionId("4c0f6cbf-173a-4bef-af7a-20919954133b")) .setQueueMessage(new QueueMessageDescriptor() .setQueue("some-queue") .setMessageId("2c71e5ce-e0bc-4d89-94b8-65a1e17126fb")) .with("foo", "some string") .with("bar", 123) .with("baz", true) .with("qux", null); SWEvent actual = MAPPER.readValue(json, SWEvent.class); assertThat(actual, is(expected)); }
public SWEvent with(String key, Object value) { map.put(key, value); return this; }
SWEvent extends ApplicationEvent { public SWEvent with(String key, Object value) { map.put(key, value); return this; } }
SWEvent extends ApplicationEvent { public SWEvent with(String key, Object value) { map.put(key, value); return this; } SWEvent(EventSourceDescriptor source, String eventType); @JsonCreator  SWEvent(@JsonProperty("source") EventSourceDescriptor source,
			@JsonProperty("timestamp") long timestamp,
			@JsonProperty("event_type") String eventType); }
SWEvent extends ApplicationEvent { public SWEvent with(String key, Object value) { map.put(key, value); return this; } SWEvent(EventSourceDescriptor source, String eventType); @JsonCreator  SWEvent(@JsonProperty("source") EventSourceDescriptor source,
			@JsonProperty("timestamp") long timestamp,
			@JsonProperty("event_type") String eventType); SWEvent with(String key, Object value); Object get(String key); @JsonAnySetter @SuppressWarnings("javadoc") void set(String key, Object value); @JsonAnyGetter @SuppressWarnings("javadoc") Map<String, Object> any(); }
SWEvent extends ApplicationEvent { public SWEvent with(String key, Object value) { map.put(key, value); return this; } SWEvent(EventSourceDescriptor source, String eventType); @JsonCreator  SWEvent(@JsonProperty("source") EventSourceDescriptor source,
			@JsonProperty("timestamp") long timestamp,
			@JsonProperty("event_type") String eventType); SWEvent with(String key, Object value); Object get(String key); @JsonAnySetter @SuppressWarnings("javadoc") void set(String key, Object value); @JsonAnyGetter @SuppressWarnings("javadoc") Map<String, Object> any();  }