Skip to content

Commit

Permalink
Merge pull request #146 from hgosansn/master
Browse files Browse the repository at this point in the history
[sc90134] [SNS] Fix for SNS topic message
  • Loading branch information
DKarim authored Feb 3, 2023
2 parents af5ad8d + cb57d55 commit 387d276
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ private PublishingArguments findArguments(Argument[] arguments) {
}
if (argument.getName().equalsIgnoreCase(MESSAGE_GROUP_ID) || argument.isAnnotationPresent(MessageGroupId.class)) {
names.messageGroupId = argument;
continue;
}
if (argument.getName().equalsIgnoreCase(MESSAGE_DEDUPLICATION_ID) || argument.isAnnotationPresent(MessageDeduplicationId.class)) {
names.messageDeduplicationId = argument;
continue;
}
names.message = argument;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@

import java.util.Map;

@NotificationClient // <1>
@NotificationClient // <1>
interface DefaultClient {

String OTHER_TOPIC = "OtherTopic";

@Topic("OtherTopic") String publishMessageToDifferentTopic(Pogo pogo); // <2>
@Topic("OtherTopic") String publishMessageToDifferentTopic(Pogo pogo); // <2>

String publishMessage(Pogo message); // <3>
String publishMessage(Pogo message); // <3>
String publishMessage(Pogo message, @MessageGroupId String groupId, @MessageDeduplicationId String deduplicationId); // <4>
String publishMessage(String subject, Pogo message); // <5>
String publishMessage(String subject, Pogo message); // <5>
String publishMessage(String subject, Pogo message, Map<String, String> attributes);
String publishMessage(String message); // <6>
String publishMessage(String message); // <6>
String publishMessage(String subject, String message);
String publishMessage(String subject, String message, Map<String, String> attributes);

String sendSMS(String phoneNumber, String message); // <7>
String sendSms(String phoneNumber, String message, Map attributes); // <8>
String sendSMS(String phoneNumber, String message); // <7>
String sendSms(String phoneNumber, String message, Map attributes); // <8>

}
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,12 @@ class NotificationClientSpec extends Specification {

then:
1 * testService.publishRequest(TestFifoClient.TOPIC_NAME, EMPTY_MAP, _) >> { String topicArn,
Map<String, String> attributes,
PublishRequest.Builder publishRequestBuilder ->
PublishRequest publishRequest = publishRequestBuilder.build()
Map<String, String> attributes,
PublishRequest.Builder publishRequestBuilder ->
PublishRequest publishRequest = publishRequestBuilder.build() as PublishRequest
assert publishRequest.messageGroupId() == MESSAGE_GROUP_ID
assert publishRequest.messageDeduplicationId() == MESSAGE_DEDUPLICATION_ID
assert publishRequest.message() == POGO_AS_JSON
return MESSAGE_ID
}
messageId == MESSAGE_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ private PublishingArguments findArguments(Argument[] arguments) {
}
if (argument.getName().equalsIgnoreCase(MESSAGE_GROUP_ID) || argument.isAnnotationPresent(MessageGroupId.class)) {
names.messageGroupId = argument;
continue;
}
if (argument.getName().equalsIgnoreCase(MESSAGE_DEDUPLICATION_ID) || argument.isAnnotationPresent(MessageDeduplicationId.class)) {
names.messageDeduplicationId = argument;
continue;
}
names.message = argument;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,29 @@
*/
package com.agorapulse.micronaut.aws.sns;

import com.agorapulse.micronaut.aws.sns.annotation.MessageDeduplicationId;
import com.agorapulse.micronaut.aws.sns.annotation.MessageGroupId;
import com.agorapulse.micronaut.aws.sns.annotation.NotificationClient;
import com.agorapulse.micronaut.aws.sns.annotation.Topic;

import java.util.Map;

@NotificationClient // <1>
@NotificationClient // <1>
interface DefaultClient {

String OTHER_TOPIC = "OtherTopic";

@Topic("OtherTopic") String publishMessageToDifferentTopic(Pogo pogo); // <2>
@Topic("OtherTopic") String publishMessageToDifferentTopic(Pogo pogo); // <2>

String publishMessage(Pogo message); // <3>
String publishMessage(String subject, Pogo message); // <4>
String publishMessage(Pogo message); // <3>
String publishMessage(Pogo message, @MessageGroupId String groupId, @MessageDeduplicationId String deduplicationId); // <4>
String publishMessage(String subject, Pogo message); // <5>
String publishMessage(String subject, Pogo message, Map<String, String> attributes);
String publishMessage(String message); // <5>
String publishMessage(String message); // <6>
String publishMessage(String subject, String message);
String publishMessage(String subject, String message, Map<String, String> attributes);

String sendSMS(String phoneNumber, String message); // <6>
String sendSms(String phoneNumber, String message, Map attributes); // <7>
String sendSMS(String phoneNumber, String message); // <7>
String sendSms(String phoneNumber, String message, Map attributes); // <8>

}

Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class NotificationClientSpec extends Specification {
1 * defaultService.publishMessageToTopic(StreamClient.SOME_STREAM, null, POGO_AS_JSON, EMPTY_MAP) >> MESSAGE_ID
}

void 'can publish to fifo topic'() {
void 'can publish pojo to fifo topic'() {
given:
TestFifoClient client = context.getBean(TestFifoClient)

Expand All @@ -179,10 +179,11 @@ class NotificationClientSpec extends Specification {

then:
1 * testService.publishRequest(TestFifoClient.TOPIC_NAME, EMPTY_MAP, _) >> { String topicArn,
Map<String, String> attributes,
PublishRequest publishRequest ->
Map<String, String> attributes,
PublishRequest publishRequest ->
assert publishRequest.messageGroupId == MESSAGE_GROUP_ID
assert publishRequest.messageDeduplicationId == MESSAGE_DEDUPLICATION_ID
assert publishRequest.message == POGO_AS_JSON
return MESSAGE_ID
}
messageId == MESSAGE_ID
Expand Down

0 comments on commit 387d276

Please sign in to comment.