Fix spelling errors in method name

This commit is contained in:
Oleg Zhurakousky
2020-11-17 16:54:23 +01:00
parent 58cde422d6
commit cd2d84d382
4 changed files with 30 additions and 25 deletions

View File

@@ -62,12 +62,12 @@ public class CloudEventAttributes extends HashMap<String, Object> {
} }
public CloudEventAttributes setId(String id) { public CloudEventAttributes setId(String id) {
this.setAtttribute(CloudEventMessageUtils.ID, id); this.setAttribute(CloudEventMessageUtils.ID, id);
return this; return this;
} }
public <A> A getId() { public <A> A getId() {
A id = this.getAtttribute(CloudEventMessageUtils.ID); A id = this.getAttribute(CloudEventMessageUtils.ID);
if (id instanceof UUID) { if (id instanceof UUID) {
id = null; id = null;
} }
@@ -75,73 +75,73 @@ public class CloudEventAttributes extends HashMap<String, Object> {
} }
public CloudEventAttributes setSource(String source) { public CloudEventAttributes setSource(String source) {
this.setAtttribute(CloudEventMessageUtils.SOURCE, source); this.setAttribute(CloudEventMessageUtils.SOURCE, source);
return this; return this;
} }
public <A> A getSource() { public <A> A getSource() {
return this.getAtttribute(CloudEventMessageUtils.SOURCE); return this.getAttribute(CloudEventMessageUtils.SOURCE);
} }
public CloudEventAttributes setSpecversion(String specversion) { public CloudEventAttributes setSpecversion(String specversion) {
this.setAtttribute(CloudEventMessageUtils.SPECVERSION, specversion); this.setAttribute(CloudEventMessageUtils.SPECVERSION, specversion);
return this; return this;
} }
public <A> A getSpecversion() { public <A> A getSpecversion() {
return this.getAtttribute(CloudEventMessageUtils.SPECVERSION); return this.getAttribute(CloudEventMessageUtils.SPECVERSION);
} }
public CloudEventAttributes setType(String type) { public CloudEventAttributes setType(String type) {
this.setAtttribute(CloudEventMessageUtils.TYPE, type); this.setAttribute(CloudEventMessageUtils.TYPE, type);
return this; return this;
} }
public <A> A getType() { public <A> A getType() {
return this.getAtttribute(CloudEventMessageUtils.TYPE); return this.getAttribute(CloudEventMessageUtils.TYPE);
} }
public CloudEventAttributes setDataContentType(String datacontenttype) { public CloudEventAttributes setDataContentType(String datacontenttype) {
this.setAtttribute(CloudEventMessageUtils.DATACONTENTTYPE, datacontenttype); this.setAttribute(CloudEventMessageUtils.DATACONTENTTYPE, datacontenttype);
return this; return this;
} }
public <A> A getDataContentType() { public <A> A getDataContentType() {
return this.getAtttribute(CloudEventMessageUtils.DATACONTENTTYPE); return this.getAttribute(CloudEventMessageUtils.DATACONTENTTYPE);
} }
public CloudEventAttributes setDataSchema(String dataschema) { public CloudEventAttributes setDataSchema(String dataschema) {
this.setAtttribute(CloudEventMessageUtils.DATASCHEMA, dataschema); this.setAttribute(CloudEventMessageUtils.DATASCHEMA, dataschema);
return this; return this;
} }
public <A> A getDataSchema() { public <A> A getDataSchema() {
return this.getAtttribute(CloudEventMessageUtils.DATASCHEMA); return this.getAttribute(CloudEventMessageUtils.DATASCHEMA);
} }
public CloudEventAttributes setSubject(String subject) { public CloudEventAttributes setSubject(String subject) {
this.setAtttribute(CloudEventMessageUtils.SUBJECT, subject); this.setAttribute(CloudEventMessageUtils.SUBJECT, subject);
return this; return this;
} }
public <A> A getSubect() { public <A> A getSubect() {
return this.getAtttribute(CloudEventMessageUtils.SUBJECT); return this.getAttribute(CloudEventMessageUtils.SUBJECT);
} }
public CloudEventAttributes setTime(String time) { public CloudEventAttributes setTime(String time) {
this.setAtttribute(CloudEventMessageUtils.TIME, time); this.setAttribute(CloudEventMessageUtils.TIME, time);
return this; return this;
} }
public <A> A getTime() { public <A> 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. * Will delegate to the underlying {@link Map} returning the value for the requested attribute or null.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <A> A getAtttribute(String attrName) { public <A> A getAttribute(String attrName) {
if (this.containsKey(CloudEventMessageUtils.DEFAULT_ATTR_PREFIX + attrName)) { if (this.containsKey(CloudEventMessageUtils.DEFAULT_ATTR_PREFIX + attrName)) {
return (A) this.get(CloudEventMessageUtils.DEFAULT_ATTR_PREFIX + attrName); return (A) this.get(CloudEventMessageUtils.DEFAULT_ATTR_PREFIX + attrName);
} }
@@ -174,7 +174,7 @@ public class CloudEventAttributes extends HashMap<String, Object> {
return attributeName; return attributeName;
} }
private CloudEventAttributes setAtttribute(String attrName, String attrValue) { private CloudEventAttributes setAttribute(String attrName, String attrValue) {
if (StringUtils.hasText(this.prefixToUse)) { if (StringUtils.hasText(this.prefixToUse)) {
this.remove(this.getAttributeName(attrName)); this.remove(this.getAttributeName(attrName));
this.put(this.prefixToUse + attrName, attrValue); this.put(this.prefixToUse + attrName, attrValue);

View File

@@ -298,7 +298,7 @@ public final class CloudEventMessageUtils {
public static CloudEventAttributes generateAttributes(Message<?> inputMessage, String typeName, String sourceName) { public static CloudEventAttributes generateAttributes(Message<?> inputMessage, String typeName, String sourceName) {
CloudEventAttributes attributes = new CloudEventAttributes(inputMessage.getHeaders(), CloudEventMessageUtils.determinePrefixToUse(inputMessage.getHeaders())); 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<String, Object> structuredCloudEvent, MessageHeaders originalHeaders) { private static Message<?> buildCeMessageFromStructured(Map<String, Object> structuredCloudEvent, MessageHeaders originalHeaders) {

View File

@@ -58,8 +58,8 @@ public class CloudEventFunctionTests {
*/ */
CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders()); CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders());
assertThat(attributes.isValidCloudEvent()).isTrue(); assertThat(attributes.isValidCloudEvent()).isTrue();
assertThat((String) attributes.getSource()).isEqualTo(Person.class.getName()); assertThat((String) attributes.getType()).isEqualTo(Person.class.getName());
assertThat((String) attributes.getType()).isEqualTo("http://spring.io/application-application"); assertThat((String) attributes.getSource()).isEqualTo("http://spring.io/application-application");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -95,8 +95,8 @@ public class CloudEventFunctionTests {
*/ */
CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders()); CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders());
assertThat(attributes.isValidCloudEvent()).isTrue(); assertThat(attributes.isValidCloudEvent()).isTrue();
assertThat((String) attributes.getSource()).isEqualTo(SpringReleaseEvent.class.getName()); assertThat((String) attributes.getType()).isEqualTo(SpringReleaseEvent.class.getName());
assertThat((String) attributes.getType()).isEqualTo("http://spring.io/application-application"); assertThat((String) attributes.getSource()).isEqualTo("http://spring.io/application-application");
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@@ -131,8 +131,8 @@ public class CloudEventFunctionTests {
*/ */
CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders()); CloudEventAttributes attributes = new CloudEventAttributes(resultMessage.getHeaders());
assertThat(attributes.isValidCloudEvent()).isTrue(); assertThat(attributes.isValidCloudEvent()).isTrue();
assertThat((String) attributes.getSource()).isEqualTo(SpringReleaseEvent.class.getName()); assertThat((String) attributes.getType()).isEqualTo(SpringReleaseEvent.class.getName());
assertThat((String) attributes.getType()).isEqualTo("http://spring.io/application-application"); assertThat((String) attributes.getSource()).isEqualTo("http://spring.io/application-application");
} }
private Function<Object, Object> lookup(String functionDefinition, Class<?>... configClass) { private Function<Object, Object> lookup(String functionDefinition, Class<?>... configClass) {

View File

@@ -101,6 +101,11 @@ public class CloudeventDemoApplicationFunctionTests {
*/ */
Function<Message<String>, Message<String>> asPojoMessage = catalog.lookup("consumeAndProduceCloudEventAsPojoToPojo"); Function<Message<String>, Message<String>> asPojoMessage = catalog.lookup("consumeAndProduceCloudEventAsPojoToPojo");
System.out.println(asPojoMessage.apply(binaryCloudEventMessage)); 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}
} }
} }
} }