Closed sweep-ai[bot] closed 6 months ago
This is an automated message generated by Sweep AI.
That is great.
No please remove classType since that can always be extracted from the passed in messageHandler.
Add a test where the message Type that is specified on the JSON is different from the messageType, and therefore MessageType is needed to translate that JSON message to a speific type.
For example, a test like the below
final void testReceivingDifferntJSONExampleEvent() {
// Arrange
String jsonMessage = "{\"messageType\":\"DefaultEvent\",\"data\":\"Hello, Default!\"}";
// Act
solaceMessageListener.onMessageReceived(jsonMessage);
// Assert
assertEquals(1, testMessageHandler.receivedEvents.size(), "Incorrect Number of Events");
ExampleEvent receivedEvent = testMessageHandler.receivedEvents.getFirst();
assertEquals("Hello, Default!", receivedEvent.getData(), "Data Mismatch");
}
and the messageHandler is defeind similar to below:
@MessageHandler(messageType = "DefaultEvent")
public final void handleExampleEvent(ExampleEvent event) {
receivedEvents.add(event);
}
Both test then need to pass.
PR Feedback: π
Description
This pull request introduces changes to the
MessageHandler
annotation and theSolaceMessageListener
class to simplify the message handling process by making themessageType
andeventClass
attributes optional. It also updates a test case to reflect these changes.Summary
MessageHandler
annotation to provide default values formessageType
andeventClass
. Now,messageType
defaults to an empty string, andeventClass
defaults toVoid.class
.SolaceMessageListener
class to automatically determinemessageType
andeventClass
if they are not explicitly provided. ThemessageType
is inferred from theeventClass
's simple name if left empty. TheeventClass
is inferred from the method parameter if set toVoid.class
.SolaceMessageListenerTest
to use theMessageHandler
annotation without specifyingmessageType
andeventClass
, demonstrating the simplified annotation usage.Fixes #4.
π Latest improvements to Sweep:
π‘ To get Sweep to edit this pull request, you can:
This is an automated message generated by Sweep AI.