From cd2d84d382e04a64d16d20d7fd9722718ab83dc3 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 17 Nov 2020 16:54:23 +0100 Subject: [PATCH] Fix spelling errors in method name --- .../cloudevent/CloudEventAttributes.java | 36 +++++++++---------- .../cloudevent/CloudEventMessageUtils.java | 2 +- .../cloudevent/CloudEventFunctionTests.java | 12 +++---- ...loudeventDemoApplicationFunctionTests.java | 5 +++ 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventAttributes.java b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventAttributes.java index 2592717cd..533eb2342 100644 --- a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventAttributes.java +++ b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventAttributes.java @@ -62,12 +62,12 @@ public class CloudEventAttributes extends HashMap { } public CloudEventAttributes setId(String id) { - this.setAtttribute(CloudEventMessageUtils.ID, id); + this.setAttribute(CloudEventMessageUtils.ID, id); return this; } public A getId() { - A id = this.getAtttribute(CloudEventMessageUtils.ID); + A id = this.getAttribute(CloudEventMessageUtils.ID); if (id instanceof UUID) { id = null; } @@ -75,73 +75,73 @@ public class CloudEventAttributes extends HashMap { } public CloudEventAttributes setSource(String source) { - this.setAtttribute(CloudEventMessageUtils.SOURCE, source); + this.setAttribute(CloudEventMessageUtils.SOURCE, source); return this; } public A getSource() { - return this.getAtttribute(CloudEventMessageUtils.SOURCE); + return this.getAttribute(CloudEventMessageUtils.SOURCE); } public CloudEventAttributes setSpecversion(String specversion) { - this.setAtttribute(CloudEventMessageUtils.SPECVERSION, specversion); + this.setAttribute(CloudEventMessageUtils.SPECVERSION, specversion); return this; } public A getSpecversion() { - return this.getAtttribute(CloudEventMessageUtils.SPECVERSION); + return this.getAttribute(CloudEventMessageUtils.SPECVERSION); } public CloudEventAttributes setType(String type) { - this.setAtttribute(CloudEventMessageUtils.TYPE, type); + this.setAttribute(CloudEventMessageUtils.TYPE, type); return this; } public A getType() { - return this.getAtttribute(CloudEventMessageUtils.TYPE); + return this.getAttribute(CloudEventMessageUtils.TYPE); } public CloudEventAttributes setDataContentType(String datacontenttype) { - this.setAtttribute(CloudEventMessageUtils.DATACONTENTTYPE, datacontenttype); + this.setAttribute(CloudEventMessageUtils.DATACONTENTTYPE, datacontenttype); return this; } public A getDataContentType() { - return this.getAtttribute(CloudEventMessageUtils.DATACONTENTTYPE); + return this.getAttribute(CloudEventMessageUtils.DATACONTENTTYPE); } public CloudEventAttributes setDataSchema(String dataschema) { - this.setAtttribute(CloudEventMessageUtils.DATASCHEMA, dataschema); + this.setAttribute(CloudEventMessageUtils.DATASCHEMA, dataschema); return this; } public A getDataSchema() { - return this.getAtttribute(CloudEventMessageUtils.DATASCHEMA); + return this.getAttribute(CloudEventMessageUtils.DATASCHEMA); } public CloudEventAttributes setSubject(String subject) { - this.setAtttribute(CloudEventMessageUtils.SUBJECT, subject); + this.setAttribute(CloudEventMessageUtils.SUBJECT, subject); return this; } public A getSubect() { - return this.getAtttribute(CloudEventMessageUtils.SUBJECT); + return this.getAttribute(CloudEventMessageUtils.SUBJECT); } public CloudEventAttributes setTime(String time) { - this.setAtttribute(CloudEventMessageUtils.TIME, time); + this.setAttribute(CloudEventMessageUtils.TIME, time); return this; } public A getTime() { - return this.getAtttribute(CloudEventMessageUtils.TIME); + return this.getAttribute(CloudEventMessageUtils.TIME); } /** * Will delegate to the underlying {@link Map} returning the value for the requested attribute or null. */ @SuppressWarnings("unchecked") - public A getAtttribute(String attrName) { + public A getAttribute(String attrName) { if (this.containsKey(CloudEventMessageUtils.DEFAULT_ATTR_PREFIX + attrName)) { return (A) this.get(CloudEventMessageUtils.DEFAULT_ATTR_PREFIX + attrName); } @@ -174,7 +174,7 @@ public class CloudEventAttributes extends HashMap { return attributeName; } - private CloudEventAttributes setAtttribute(String attrName, String attrValue) { + private CloudEventAttributes setAttribute(String attrName, String attrValue) { if (StringUtils.hasText(this.prefixToUse)) { this.remove(this.getAttributeName(attrName)); this.put(this.prefixToUse + attrName, attrValue); diff --git a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventMessageUtils.java b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventMessageUtils.java index 0ee33f648..36843c4d3 100644 --- a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventMessageUtils.java +++ b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/cloudevent/CloudEventMessageUtils.java @@ -298,7 +298,7 @@ public final class CloudEventMessageUtils { public static CloudEventAttributes generateAttributes(Message inputMessage, String typeName, String sourceName) { CloudEventAttributes attributes = new CloudEventAttributes(inputMessage.getHeaders(), CloudEventMessageUtils.determinePrefixToUse(inputMessage.getHeaders())); - return generateDefaultAttributeValues(attributes, typeName, sourceName); + return generateDefaultAttributeValues(attributes, sourceName, typeName); } private static Message buildCeMessageFromStructured(Map structuredCloudEvent, MessageHeaders originalHeaders) { diff --git a/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/cloudevent/CloudEventFunctionTests.java b/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/cloudevent/CloudEventFunctionTests.java index ba5f7187f..96a5661bf 100644 --- a/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/cloudevent/CloudEventFunctionTests.java +++ b/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/cloudevent/CloudEventFunctionTests.java @@ -58,8 +58,8 @@ public class CloudEventFunctionTests { */ CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders()); assertThat(attributes.isValidCloudEvent()).isTrue(); - assertThat((String) attributes.getSource()).isEqualTo(Person.class.getName()); - assertThat((String) attributes.getType()).isEqualTo("http://spring.io/application-application"); + assertThat((String) attributes.getType()).isEqualTo(Person.class.getName()); + assertThat((String) attributes.getSource()).isEqualTo("http://spring.io/application-application"); } @SuppressWarnings("unchecked") @@ -95,8 +95,8 @@ public class CloudEventFunctionTests { */ CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders()); assertThat(attributes.isValidCloudEvent()).isTrue(); - assertThat((String) attributes.getSource()).isEqualTo(SpringReleaseEvent.class.getName()); - assertThat((String) attributes.getType()).isEqualTo("http://spring.io/application-application"); + assertThat((String) attributes.getType()).isEqualTo(SpringReleaseEvent.class.getName()); + assertThat((String) attributes.getSource()).isEqualTo("http://spring.io/application-application"); } @SuppressWarnings("unchecked") @@ -131,8 +131,8 @@ public class CloudEventFunctionTests { */ CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders()); assertThat(attributes.isValidCloudEvent()).isTrue(); - assertThat((String) attributes.getSource()).isEqualTo(SpringReleaseEvent.class.getName()); - assertThat((String) attributes.getType()).isEqualTo("http://spring.io/application-application"); + assertThat((String) attributes.getType()).isEqualTo(SpringReleaseEvent.class.getName()); + assertThat((String) attributes.getSource()).isEqualTo("http://spring.io/application-application"); } private Function lookup(String functionDefinition, Class... configClass) { diff --git a/spring-cloud-function-samples/function-sample-cloudevent/src/test/java/io/spring/cloudevent/CloudeventDemoApplicationFunctionTests.java b/spring-cloud-function-samples/function-sample-cloudevent/src/test/java/io/spring/cloudevent/CloudeventDemoApplicationFunctionTests.java index acefaf273..592ed20e0 100644 --- a/spring-cloud-function-samples/function-sample-cloudevent/src/test/java/io/spring/cloudevent/CloudeventDemoApplicationFunctionTests.java +++ b/spring-cloud-function-samples/function-sample-cloudevent/src/test/java/io/spring/cloudevent/CloudeventDemoApplicationFunctionTests.java @@ -101,6 +101,11 @@ public class CloudeventDemoApplicationFunctionTests { */ Function, Message> asPojoMessage = catalog.lookup("consumeAndProduceCloudEventAsPojoToPojo"); System.out.println(asPojoMessage.apply(binaryCloudEventMessage)); + //ce_source=https://interface21.com/ +// ce_type=com.interface21 + //ce_type=com.interface21, ce_source=https://interface21.com/ + //{ce_type=http://spring.io/application-application, ce_source=io.spring.cloudevent.SpringReleaseEvent, ce_specversion=1.0, ce_id=eba0eda2-ab01-4f62-b369-6eb473106c4a, id=e31a2670-6000-4954-1b90-a864d2ac6fc6, timestamp=1605627860374} + //{ce_type=io.spring.cloudevent.SpringReleaseEvent, ce_source=http://spring.io/application-application, ce_specversion=1.0, ce_id=93980c85-c478-471f-8a00-69bf288fe22b, id=2ded0773-3a78-8e73-feb5-7274f5439d64, timestamp=1605627907645} } } }