Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
This commit is contained in:
Francesco Guardiani 2021-04-28 15:15:45 +02:00 committed by GitHub
parent 2730ae4a13
commit 78355bb225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 11 deletions

View File

@ -236,12 +236,12 @@ public final class CloudEventV03 extends BaseCloudEvent {
"id='" + id + '\'' +
", source=" + source +
", type='" + type + '\'' +
", datacontenttype='" + datacontenttype + '\'' +
", schemaurl=" + schemaurl +
", subject='" + subject + '\'' +
", time=" + time +
", data=" + getData() +
", extensions" + this.extensions +
((datacontenttype != null) ? ", datacontenttype='" + datacontenttype + '\'' : "") +
((schemaurl != null) ? ", schemaurl=" + schemaurl : "") +
((subject != null) ? ", subject='" + subject + '\'' : "") +
((time != null) ? ", time=" + time : "") +
((getData() != null) ? ", data=" + getData() : "") +
", extensions=" + this.extensions +
'}';
}
}

View File

@ -223,11 +223,11 @@ public final class CloudEventV1 extends BaseCloudEvent {
"id='" + id + '\'' +
", source=" + source +
", type='" + type + '\'' +
", datacontenttype='" + datacontenttype + '\'' +
", dataschema=" + dataschema +
", subject='" + subject + '\'' +
", time=" + time +
", data=" + getData() +
((datacontenttype != null) ? ", datacontenttype='" + datacontenttype + '\'' : "") +
((dataschema != null) ? ", dataschema=" + dataschema : "") +
((subject != null) ? ", subject='" + subject + '\'' : "") +
((time != null) ? ", time=" + time : "") +
((getData() != null) ? ", data=" + getData() : "") +
", extensions=" + this.extensions +
'}';
}

View File

@ -91,4 +91,28 @@ public class CloudEventImplTest {
);
}
@Test
public void testToStringV1() {
CloudEvent event = CloudEventBuilder.v1()
.withId(ID)
.withType(TYPE)
.withSource(SOURCE)
.build();
assertThat(event.toString())
.doesNotContain("time");
}
@Test
public void testToStringV03() {
CloudEvent event = CloudEventBuilder.v03()
.withId(ID)
.withType(TYPE)
.withSource(SOURCE)
.build();
assertThat(event.toString())
.doesNotContain("time");
}
}