From 0b2585048c994da4264022f63bc284b800c34af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 17:51:08 -0300 Subject: [PATCH 01/10] Deps for Bean Validation 2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- api/pom.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/pom.xml b/api/pom.xml index a9601e97..2f60547a 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -42,6 +42,18 @@ jackson-datatype-jdk8 ${jackson.version} + + + org.hibernate.validator + hibernate-validator + ${hibernate-validator.version} + + + + org.glassfish + javax.el + ${javax.el.version} + junit @@ -61,6 +73,8 @@ 2.9.6 + 6.0.17.Final + 3.0.1-b11 From 6b3253797238ee78a4ff32772e49c47dc9d74794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 17:52:06 -0300 Subject: [PATCH 02/10] Adding alias to work with 'contenttype' and 'contentType' on deserialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- api/src/main/java/io/cloudevents/impl/DefaultCloudEventImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/main/java/io/cloudevents/impl/DefaultCloudEventImpl.java b/api/src/main/java/io/cloudevents/impl/DefaultCloudEventImpl.java index dcec374d..51f163db 100644 --- a/api/src/main/java/io/cloudevents/impl/DefaultCloudEventImpl.java +++ b/api/src/main/java/io/cloudevents/impl/DefaultCloudEventImpl.java @@ -140,6 +140,7 @@ public class DefaultCloudEventImpl implements CloudEvent, Serializable { this.schemaURL = schemaURL; } + @JsonAlias("contenttype") void setContentType(String contentType) { this.contentType = contentType; } From f11c773f8a27fb9fbb73206d2d440827e6d08338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 17:52:46 -0300 Subject: [PATCH 03/10] content type as lowercase, as-is spec v0.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- api/src/test/resources/02_aws.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/test/resources/02_aws.json b/api/src/test/resources/02_aws.json index b069e17b..658da98a 100644 --- a/api/src/test/resources/02_aws.json +++ b/api/src/test/resources/02_aws.json @@ -3,7 +3,7 @@ "id": "C234-1234-1234", "time": "2018-04-26T14:48:09.769Z", "source": "https://serverless.com", - "contentType": "application/json", + "contenttype": "application/json", "specversion": "0.2", "data": { "s3SchemaVersion": "1.0", From 47ca69c4357031be489395adcdbc87f3689868ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 17:53:15 -0300 Subject: [PATCH 04/10] fromInputStream using generics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- api/src/main/java/io/cloudevents/json/Json.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/io/cloudevents/json/Json.java b/api/src/main/java/io/cloudevents/json/Json.java index ec559276..2e4f4360 100644 --- a/api/src/main/java/io/cloudevents/json/Json.java +++ b/api/src/main/java/io/cloudevents/json/Json.java @@ -61,7 +61,17 @@ public final class Json { throw new IllegalStateException("Failed to encode as JSON: " + e.getMessage()); } } - + + public static T fromInputStream(final InputStream inputStream, + Class clazz) { + try { + return MAPPER.readValue(inputStream, clazz); + } catch (Exception e) { + throw new IllegalStateException("Failed to encode as JSON: " + + e.getMessage()); + } + } + /** * Decode a given JSON string to a CloudEvent . * From cee02dead897e61fddcac6facdfd9093e66b3563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 17:56:31 -0300 Subject: [PATCH 05/10] Exclusive impl for spec 0.2. Closes #32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- .../java/io/cloudevents/v02/CloudEvent.java | 112 +++++++++ .../io/cloudevents/v02/CloudEventBuilder.java | 103 ++++++++ .../v02/CloudEventBuilderTest.java | 221 ++++++++++++++++++ .../v02/CloudEventJacksonTest.java | 134 +++++++++++ api/src/test/resources/02_absent.json | 7 + 5 files changed, 577 insertions(+) create mode 100644 api/src/main/java/io/cloudevents/v02/CloudEvent.java create mode 100644 api/src/main/java/io/cloudevents/v02/CloudEventBuilder.java create mode 100644 api/src/test/java/io/cloudevents/v02/CloudEventBuilderTest.java create mode 100644 api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java create mode 100644 api/src/test/resources/02_absent.json diff --git a/api/src/main/java/io/cloudevents/v02/CloudEvent.java b/api/src/main/java/io/cloudevents/v02/CloudEvent.java new file mode 100644 index 00000000..5439b119 --- /dev/null +++ b/api/src/main/java/io/cloudevents/v02/CloudEvent.java @@ -0,0 +1,112 @@ +package io.cloudevents.v02; + +import java.net.URI; +import java.time.ZonedDateTime; +import java.util.Optional; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import io.cloudevents.json.ZonedDateTimeDeserializer; + +/** + * + * @author fabiojose + * + * Implemented using immutable data structure. + * + */ +@JsonInclude(value = Include.NON_ABSENT) +public class CloudEvent { + + @NotBlank + private final String type; + + @NotBlank + @Pattern(regexp = "0\\.2") + private final String specversion; + + @NotNull + private final URI source; + + @NotBlank + private final String id; + + private final ZonedDateTime time; + private final URI schemaurl; + private final String contenttype; + + private final T data; + + public CloudEvent(String id, URI source, String specversion, String type, + ZonedDateTime time, URI schemaurl, String contenttype, + T data) { + + this.id = id; + this.source = source; + this.specversion = specversion; + this.type = type; + + this.time = time; + this.schemaurl = schemaurl; + this.contenttype = contenttype; + + this.data = data; + } + + public String getType() { + return type; + } + public String getId() { + return id; + } + public String getSpecversion() { + return specversion; + } + public URI getSource() { + return source; + } + + @JsonDeserialize(using = ZonedDateTimeDeserializer.class) + public Optional getTime() { + return Optional.ofNullable(time); + } + public Optional getSchemaurl() { + return Optional.ofNullable(schemaurl); + } + public Optional getContenttype() { + return Optional.ofNullable(contenttype); + } + public Optional getData() { + return Optional.ofNullable(data); + } + + @JsonCreator + public static CloudEvent build( + @JsonProperty("id") String id, + @JsonProperty("source") URI source, + @JsonProperty("specversion") String specversion, + @JsonProperty("type") String type, + @JsonProperty("time") ZonedDateTime time, + @JsonProperty("schemaurl") URI schemaurl, + @JsonProperty("contenttype") String contenttype, + @JsonProperty("data") T data) { + + return new CloudEventBuilder() + .withId(id) + .withSource(source) + .withType(type) + .withTime(time) + .withSchemaurl(schemaurl) + .withContenttype(contenttype) + .withData(data) + .build(); + } +} diff --git a/api/src/main/java/io/cloudevents/v02/CloudEventBuilder.java b/api/src/main/java/io/cloudevents/v02/CloudEventBuilder.java new file mode 100644 index 00000000..8e4aa31b --- /dev/null +++ b/api/src/main/java/io/cloudevents/v02/CloudEventBuilder.java @@ -0,0 +1,103 @@ +package io.cloudevents.v02; + +import static java.lang.String.format; + +import java.net.URI; +import java.time.ZonedDateTime; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; + +/** + * CloudEvent instances builder + * + * @author fabiojose + * + */ +public class CloudEventBuilder { + + private static final String SPEC_VERSION = "0.2"; + private static final String MESSAGE_SEPARATOR = ", "; + private static final String MESSAGE = "'%s' %s"; + private static final String ERR_MESSAGE = "invalid payload: %s"; + + private String type; + private String id; + private URI source; + + private ZonedDateTime time; + private URI schemaurl; + private String contenttype; + private T data; + + private Validator getValidator() { + return Validation.buildDefaultValidatorFactory().getValidator(); + } + + /** + * + * @return An new {@link CloudEvent} immutable instance + * @throws IllegalStateException When there are specification constraints + * violations + */ + public CloudEvent build() { + CloudEvent event = new CloudEvent<>(id, source, SPEC_VERSION, type, + time, schemaurl, contenttype, data); + + Set>> violations = + getValidator().validate(event); + + final String errs = + violations.stream() + .map(v -> format(MESSAGE, v.getPropertyPath(), v.getMessage())) + .collect(Collectors.joining(MESSAGE_SEPARATOR)); + + Optional.ofNullable( + "".equals(errs) ? null : errs + + ).ifPresent((e) -> { + throw new IllegalStateException(format(ERR_MESSAGE, e)); + }); + + return event; + } + + public CloudEventBuilder withType(String type) { + this.type = type; + return this; + } + + public CloudEventBuilder withId(String id) { + this.id = id; + return this; + } + + public CloudEventBuilder withSource(URI source) { + this.source = source; + return this; + } + + public CloudEventBuilder withTime(ZonedDateTime time) { + this.time = time; + return this; + } + + public CloudEventBuilder withSchemaurl(URI schemaurl) { + this.schemaurl = schemaurl; + return this; + } + + public CloudEventBuilder withContenttype(String contenttype) { + this.contenttype = contenttype; + return this; + } + + public CloudEventBuilder withData(T data) { + this.data = data; + return this; + } +} diff --git a/api/src/test/java/io/cloudevents/v02/CloudEventBuilderTest.java b/api/src/test/java/io/cloudevents/v02/CloudEventBuilderTest.java new file mode 100644 index 00000000..11d3229e --- /dev/null +++ b/api/src/test/java/io/cloudevents/v02/CloudEventBuilderTest.java @@ -0,0 +1,221 @@ +package io.cloudevents.v02; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.net.URI; +import java.time.ZonedDateTime; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * + * @author fabiojose + * + */ +public class CloudEventBuilderTest { + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public void error_when_null_id() { + // setup + expectedEx.expect(IllegalStateException.class); + expectedEx.expectMessage("invalid payload: 'id' must not be blank"); + + // act + new CloudEventBuilder() + .withSource(URI.create("/test")) + .withType("type") + .build(); + } + + @Test + public void error_when_empty_id() { + // setup + expectedEx.expect(IllegalStateException.class); + expectedEx.expectMessage("invalid payload: 'id' must not be blank"); + + // act + new CloudEventBuilder() + .withId("") + .withSource(URI.create("/test")) + .withType("type") + .build(); + } + + @Test + public void error_when_null_type() { + // setup + expectedEx.expect(IllegalStateException.class); + expectedEx.expectMessage("invalid payload: 'type' must not be blank"); + + // act + new CloudEventBuilder() + .withId("id") + .withSource(URI.create("/test")) + .build(); + } + + @Test + public void error_when_empty_type() { + // setup + expectedEx.expect(IllegalStateException.class); + expectedEx.expectMessage("invalid payload: 'type' must not be blank"); + + // act + new CloudEventBuilder() + .withId("id") + .withSource(URI.create("/test")) + .withType("") + .build(); + } + + @Test + public void error_when_null_source() { + // setup + expectedEx.expect(IllegalStateException.class); + expectedEx.expectMessage("invalid payload: 'source' must not be null"); + + // act + new CloudEventBuilder() + .withId("id") + .withType("type") + .build(); + } + + @Test + public void should_have_id() { + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .build(); + + // assert + assertEquals("id", ce.getId()); + } + + @Test + public void should_have_source() { + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .build(); + + // assert + assertEquals(URI.create("/source"), ce.getSource()); + } + + @Test + public void should_have_type() { + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .build(); + + // assert + assertEquals("type", ce.getType()); + } + + @Test + public void should_have_specversion() { + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .build(); + + // assert + assertEquals("0.2", ce.getSpecversion()); + } + + @Test + public void should_have_time() { + // setup + ZonedDateTime expected = ZonedDateTime.now(); + + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .withTime(expected) + .build(); + + // assert + assertTrue(ce.getTime().isPresent()); + assertEquals(expected, ce.getTime().get()); + } + + @Test + public void should_have_schemaurl() { + // setup + URI expected = URI.create("/schema"); + + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .withSchemaurl(expected) + .build(); + + // assert + assertTrue(ce.getSchemaurl().isPresent()); + assertEquals(expected, ce.getSchemaurl().get()); + } + + @Test + public void should_have_contenttype() { + // setup + String expected = "application/json"; + + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .withContenttype(expected) + .build(); + + // assert + assertTrue(ce.getContenttype().isPresent()); + assertEquals(expected, ce.getContenttype().get()); + } + + @Test + public void should_have_data() { + // setup + String expected = "my data"; + + // act + CloudEvent ce = + new CloudEventBuilder<>() + .withId("id") + .withSource(URI.create("/source")) + .withType("type") + .withData(expected) + .build(); + + // assert + assertTrue(ce.getData().isPresent()); + assertEquals(expected, ce.getData().get()); + } +} diff --git a/api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java b/api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java new file mode 100644 index 00000000..265c25ea --- /dev/null +++ b/api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java @@ -0,0 +1,134 @@ +package io.cloudevents.v02; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.net.URI; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import io.cloudevents.json.Json; + +/** + * + * @author fabiojose + * + */ +public class CloudEventJacksonTest { + + private static InputStream resourceOf(String name) { + return Thread.currentThread().getContextClassLoader().getResourceAsStream(name); + } + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public void should_encode_right_with_minimal_attrs() { + // setup + CloudEvent ce = + new CloudEventBuilder<>() + .withId("x10") + .withSource(URI.create("/source")) + .withType("event-type") + .build(); + + // act + String json = Json.encode(ce); + + // assert + assertTrue(json.contains("x10")); + assertTrue(json.contains("/source")); + assertTrue(json.contains("event-type")); + assertTrue(json.contains("0.2")); + + assertFalse(json.contains("time")); + assertFalse(json.contains("schemaurl")); + assertFalse(json.contains("contenttype")); + assertFalse(json.contains("data")); + } + + @Test + public void should_have_optional_attrs() { + // setup + CloudEvent ce = + new CloudEventBuilder<>() + .withId("x10") + .withSource(URI.create("/source")) + .withType("event-type") + .withSchemaurl(URI.create("/schema")) + .withContenttype("text/plain") + .withData("my-data") + .build(); + + // act + String json = Json.encode(ce); + + // assert + assertTrue(json.contains("/schema")); + assertTrue(json.contains("text/plain")); + assertTrue(json.contains("my-data")); + } + + @Test + public void should_have_type() { + // act + CloudEvent ce = Json.fromInputStream(resourceOf("02_aws.json"), CloudEvent.class); + + // assert + assertEquals("aws.s3.object.created", ce.getType()); + } + + @Test + public void should_have_id() { + // act + CloudEvent ce = Json.fromInputStream(resourceOf("02_aws.json"), CloudEvent.class); + + // assert + assertEquals("C234-1234-1234", ce.getId()); + } + + //should have time + + @Test + public void should_have_source() { + // act + CloudEvent ce = Json.fromInputStream(resourceOf("02_aws.json"), CloudEvent.class); + + // assert + assertEquals(URI.create("https://serverless.com"), ce.getSource()); + } + + @Test + public void should_have_contenttype() { + // act + CloudEvent ce = Json.fromInputStream(resourceOf("02_aws.json"), CloudEvent.class); + + // assert + assertTrue(ce.getContenttype().isPresent()); + assertEquals("application/json", ce.getContenttype().get()); + } + + @Test + public void should_have_specversion() { + // act + CloudEvent ce = Json.fromInputStream(resourceOf("02_aws.json"), CloudEvent.class); + + // assert + assertEquals("0.2", ce.getSpecversion()); + } + + @Test + public void should_throw_when_absent() { + // setup + expectedEx.expect(IllegalStateException.class); + expectedEx.expectMessage("invalid payload: 'id' must not be blank"); + + // act + Json.fromInputStream(resourceOf("02_absent.json"), CloudEvent.class); + } +} diff --git a/api/src/test/resources/02_absent.json b/api/src/test/resources/02_absent.json new file mode 100644 index 00000000..18e4682f --- /dev/null +++ b/api/src/test/resources/02_absent.json @@ -0,0 +1,7 @@ +{ + "type": "aws.s3.object.created", + "time": "2018-04-26T14:48:09.769Z", + "source": "https://serverless.com", + "contenttype": "application/json", + "specversion": "0.2" +} \ No newline at end of file From af57ffb57d07eace57f3e073a50dfaa0fc078726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 17:59:24 -0300 Subject: [PATCH 06/10] Package level constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- api/src/main/java/io/cloudevents/v02/CloudEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/io/cloudevents/v02/CloudEvent.java b/api/src/main/java/io/cloudevents/v02/CloudEvent.java index 5439b119..9c0fc2d4 100644 --- a/api/src/main/java/io/cloudevents/v02/CloudEvent.java +++ b/api/src/main/java/io/cloudevents/v02/CloudEvent.java @@ -45,7 +45,7 @@ public class CloudEvent { private final T data; - public CloudEvent(String id, URI source, String specversion, String type, + CloudEvent(String id, URI source, String specversion, String type, ZonedDateTime time, URI schemaurl, String contenttype, T data) { From 9f2d568598934b7ad30f1914a15aaf8269f9ee7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 18:01:01 -0300 Subject: [PATCH 07/10] Test for time attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- .../java/io/cloudevents/v02/CloudEventJacksonTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java b/api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java index 265c25ea..140390a6 100644 --- a/api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java +++ b/api/src/test/java/io/cloudevents/v02/CloudEventJacksonTest.java @@ -93,6 +93,14 @@ public class CloudEventJacksonTest { } //should have time + @Test + public void should_have_time() { + // act + CloudEvent ce = Json.fromInputStream(resourceOf("02_aws.json"), CloudEvent.class); + + // assert + assertTrue(ce.getTime().isPresent()); + } @Test public void should_have_source() { From 8350a78ce5ab2800e2323f817354a0189215020a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 18:10:36 -0300 Subject: [PATCH 08/10] Add fabiojose as developer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 8dd6c33c..ce03002f 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,10 @@ jponge Julien Ponge + + fabiojose + Fabio José de Moraes + From 935c17bb162ac4a2598348d8899be35ce1ac5361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 18:16:25 -0300 Subject: [PATCH 09/10] Document the new way to create typed event and update the version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8181231d..9dcfd2a6 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,17 @@ For Maven based projects, use the following to configure the CloudEvents Java SD io.cloudevents cloudevents-api - 0.2.1 + 0.2.2 ``` Application developers can now create strongly-typed CloudEvents, such as: ```java +import io.cloudevents.v02.CloudEventBuilder; +import io.cloudevents.v02.CloudEvent; +import io.cloudevents.json.Json; + // given final String eventId = UUID.randomUUID().toString(); final URI src = URI.create("/trigger"); @@ -34,11 +38,14 @@ final MyCustomEvent payload = ... // passing in the given attributes final CloudEvent cloudEvent = new CloudEventBuilder() - .type(eventType) - .id(eventId) - .source(src) - .data(payload) + .withType(eventType) + .withId(eventId) + .withSource(src) + .withData(payload) .build(); + +// marshalling as json +final String json = Json.encode(cloudEvent); ``` ## Possible Integrations From 5326476d5512848fde361c0e8437269907c6ca3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Tue, 13 Aug 2019 19:01:27 -0300 Subject: [PATCH 10/10] Remove the oraclejdk8 due the ci error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1847f02b..fb2aab3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: java sudo: false jdk: - - oraclejdk8 - openjdk8 - openjdk9 - openjdk10