use of com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class EnvironmentInstancesNotificationSetupTest method setupExpectedRes.
private CreateTopicResult setupExpectedRes(StackEnvironmentType env, CreateTopicRequest req) {
String topicArn = "arn:" + req.getName();
String protocol = Constants.TOPIC_SUBSCRIBE_PROTOCOL_EMAIL;
String endpoint = config.getEnvironmentInstanceNotificationEndpoint(env);
CreateTopicResult expectedRes = new CreateTopicResult().withTopicArn(topicArn);
when(mockClient.createTopic(req)).thenReturn(expectedRes);
ListSubscriptionsByTopicRequest tRequest = new ListSubscriptionsByTopicRequest().withTopicArn(topicArn);
Subscription expected = new Subscription().withEndpoint(endpoint).withProtocol(protocol);
ListSubscriptionsByTopicResult result = new ListSubscriptionsByTopicResult().withSubscriptions(expected);
when(mockClient.listSubscriptionsByTopic(tRequest)).thenReturn(result);
return expectedRes;
}
use of com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class NotificationUtilsTest method testCreateSubscriptionDoesNotExist.
@Test
public void testCreateSubscriptionDoesNotExist() {
String topicArn = "arn:123";
String protocol = "email";
String endpoint = "testing@domain.com";
ListSubscriptionsByTopicRequest tRequest = new ListSubscriptionsByTopicRequest().withTopicArn(topicArn);
ListSubscriptionsByTopicResult result = new ListSubscriptionsByTopicResult().withSubscriptions(new Subscription().withEndpoint("nomatch").withProtocol("noMatch"));
when(mockClient.listSubscriptionsByTopic(tRequest)).thenReturn(result);
// This should call create
SubscribeRequest expectedRequest = new SubscribeRequest();
expectedRequest.setTopicArn(topicArn);
expectedRequest.setProtocol(protocol);
expectedRequest.setEndpoint(endpoint);
Subscription sub = NotificationUtils.createSubScription(mockClient, topicArn, protocol, endpoint);
assertNull(sub);
verify(mockClient, times(1)).subscribe(expectedRequest);
}
use of com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult in project Synapse-Stack-Builder by Sage-Bionetworks.
the class NotificationUtilsTest method testfindSubscriptionDoesNotExist.
@Test
public void testfindSubscriptionDoesNotExist() {
String topicArn = "arn:123";
String protocol = "email";
String endpoint = "testing@domain.com";
ListSubscriptionsByTopicRequest tRequest = new ListSubscriptionsByTopicRequest().withTopicArn(topicArn);
ListSubscriptionsByTopicResult result = new ListSubscriptionsByTopicResult().withSubscriptions(new Subscription().withEndpoint("nomatch").withProtocol("noMatch"));
when(mockClient.listSubscriptionsByTopic(tRequest)).thenReturn(result);
// For this case it should not be found
Subscription sub = NotificationUtils.findSubscription(mockClient, topicArn, protocol, endpoint);
assertNull(sub);
}
Aggregations