Skip to content

Commit

Permalink
Add dataType property to output / trigger annotation for Java (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan committed Oct 17, 2022
1 parent a46b8df commit bbd4a43
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following attributes are common to both RabbitMQ trigger and output bindings
| `ConnectionStringSetting` | string | The setting name for RabbitMQ connection URI. An example setting value would be `amqp://user:pass@host:10000/vhost`. |
| `QueueName` | string | The RabbitMQ queue name. |
| `DisableCertificateValidation` | boolean | Indicates whether certificate validation should be disabled. Not recommended for production. Does not apply when SSL is disabled. |
| `dataType` | string | DataType of the message. "" by default as String, "binary" for byte[]|

## Further Reading

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,14 @@
* production. Does not apply when SSL is disabled.
*/
boolean disableCertificateValidation() default false;

/**
* <p>Defines how Functions runtime should treat the parameter value. Possible values are:</p>
* <ul>
* <li>"" or string: treat it as a string whose value is serialized from the parameter</li>
* <li>binary: treat it as a binary data whose value comes from for example OutputBinding&lt;byte[]&lt;</li>
* </ul>
* @return The dataType which will be used by the Functions runtime.
*/
String dataType() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,15 @@
* production. Does not apply when SSL is disabled.
*/
boolean disableCertificateValidation() default false;

/**
* <p>Defines how Functions runtime should treat the parameter value. Possible values are:</p>
* <ul>
* <li>"": get the value as a string, and try to deserialize to actual parameter type like POJO</li>
* <li>string: always get the value as a string</li>
* <li>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[]</li>
* </ul>
* @return The dataType which will be used by the Functions runtime.
*/
String dataType() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public void TestRabbitMQOutput() {
EasyMock.expect(outputMock.queueName()).andReturn("dummyQueueName");
EasyMock.expect(outputMock.connectionStringSetting()).andReturn("dummyConnectionStringSetting");
EasyMock.expect(outputMock.disableCertificateValidation()).andReturn(true);
EasyMock.expect(outputMock.dataType()).andReturn("string");
EasyMock.replay(outputMock);

Assert.assertEquals("dummyQueueName", outputMock.queueName());
Assert.assertEquals("dummyConnectionStringSetting", outputMock.connectionStringSetting());
Assert.assertEquals(true, outputMock.disableCertificateValidation());
Assert.assertEquals("string", outputMock.dataType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ public void TestRabbitMQTrigger() {
EasyMock.expect(triggerMock.queueName()).andReturn("dummyQueueName");
EasyMock.expect(triggerMock.connectionStringSetting()).andReturn("dummyConnectionStringSetting");
EasyMock.expect(triggerMock.disableCertificateValidation()).andReturn(true);
EasyMock.expect(triggerMock.dataType()).andReturn("string");
EasyMock.replay(triggerMock);

Assert.assertEquals("dummyQueueName", triggerMock.queueName());
Assert.assertEquals("dummyConnectionStringSetting", triggerMock.connectionStringSetting());
Assert.assertEquals(true, triggerMock.disableCertificateValidation());
Assert.assertEquals("string", triggerMock.dataType());
}
}

0 comments on commit bbd4a43

Please sign in to comment.