@Test public void testFullSerialize() throws Exception { 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 sut = new SWEvent(source, "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) .with("quux", Arrays.asList(1, 2, 3)) .with("corge", Arrays.asList("a", "bb", "ccc")) .with("grault", Arrays.asList("s", false, 12)) .with("garply", ImmutableMap.of("a", "abc", "b", true, "c", 23)); log.info("ToString: {}", sut.toString()); String actual = MAPPER.writeValueAsString(sut); log.info("ToJson: {}", actual); assertThat(actual, isJson()); assertThat(actual, hasJsonPath("$.timestamp")); assertThat(actual, hasJsonPath("$.event_type", is("test_event"))); assertThat(actual, hasJsonPath("$.source.environment.account_id", is("000011112222"))); assertThat(actual, hasJsonPath("$.source.environment.region", is("ap-northeast-1"))); assertThat(actual, hasJsonPath("$.source.environment.instance_id", is("i-0123456789abcdef"))); assertThat(actual, hasJsonPath("$.source.product.name", is("foobar"))); assertThat(actual, hasJsonPath("$.source.product.role", is("bazqux"))); assertThat(actual, hasJsonPath("$.source.product.version", is("1.23"))); assertThat(actual, hasJsonPath("$.authentication.client_id", is("test.client01"))); assertThat(actual, hasJsonPath("$.authentication.username", is("test.user01"))); assertThat(actual, hasJsonPath("$.request.request_id", is("57e4e60b-fd57-402f-a5f2-bc984fa63c16"))); assertThat(actual, hasJsonPath("$.request.uri", is("http: assertThat(actual, hasJsonPath("$.request.method", is("GET"))); assertThat(actual, hasJsonPath("$.request.remote_addr", is("203.0.113.3"))); assertThat(actual, hasJsonPath("$.request.remote_host", is("203.0.113.3"))); assertThat(actual, hasJsonPath("$.request.session_id", is("4c0f6cbf-173a-4bef-af7a-20919954133b"))); assertThat(actual, hasJsonPath("$.message.queue", is("some-queue"))); assertThat(actual, hasJsonPath("$.message.message_id", is("2c71e5ce-e0bc-4d89-94b8-65a1e17126fb"))); assertThat(actual, hasJsonPath("$.foo", is("some string"))); assertThat(actual, hasJsonPath("$.bar", is(123))); assertThat(actual, hasJsonPath("$.baz", is(true))); assertThat(actual, hasJsonPath("$.qux", is(nullValue()))); assertThat(actual, hasJsonPath("$.quux", hasSize(3))); assertThat(actual, hasJsonPath("$.quux", hasItems(1, 2, 3))); assertThat(actual, hasJsonPath("$.corge", hasSize(3))); assertThat(actual, hasJsonPath("$.corge[0]", is("a"))); assertThat(actual, hasJsonPath("$.corge[1]", is("bb"))); assertThat(actual, hasJsonPath("$.corge[2]", is("ccc"))); assertThat(actual, hasJsonPath("$.grault", hasSize(3))); assertThat(actual, hasJsonPath("$.grault[0]", is("s"))); assertThat(actual, hasJsonPath("$.grault[1]", is(false))); assertThat(actual, hasJsonPath("$.grault[2]", is(12))); assertThat(actual, hasJsonPath("$.garply.a", is("abc"))); assertThat(actual, hasJsonPath("$.garply.b", is(true))); assertThat(actual, hasJsonPath("$.garply.c", is(23))); }
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();  }