Search in sources :

Example 6 with ListSubscriptionsByTopicResult

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;
}
Also used : CreateTopicResult(com.amazonaws.services.sns.model.CreateTopicResult) ListSubscriptionsByTopicResult(com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult) ListSubscriptionsByTopicRequest(com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest) Subscription(com.amazonaws.services.sns.model.Subscription)

Example 7 with ListSubscriptionsByTopicResult

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);
}
Also used : SubscribeRequest(com.amazonaws.services.sns.model.SubscribeRequest) ListSubscriptionsByTopicResult(com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult) ListSubscriptionsByTopicRequest(com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest) Subscription(com.amazonaws.services.sns.model.Subscription) Test(org.junit.Test)

Example 8 with ListSubscriptionsByTopicResult

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);
}
Also used : ListSubscriptionsByTopicResult(com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult) ListSubscriptionsByTopicRequest(com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest) Subscription(com.amazonaws.services.sns.model.Subscription) Test(org.junit.Test)

Aggregations

ListSubscriptionsByTopicRequest (com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest)8 ListSubscriptionsByTopicResult (com.amazonaws.services.sns.model.ListSubscriptionsByTopicResult)8 Subscription (com.amazonaws.services.sns.model.Subscription)8 Test (org.junit.Test)5 CreateTopicResult (com.amazonaws.services.sns.model.CreateTopicResult)3 CreateTopicRequest (com.amazonaws.services.sns.model.CreateTopicRequest)2 SubscribeRequest (com.amazonaws.services.sns.model.SubscribeRequest)2 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 DescribeSecurityGroupsRequest (com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest)1 DescribeSecurityGroupsResult (com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult)1 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)1 AmazonRDSClient (com.amazonaws.services.rds.AmazonRDSClient)1 DBParameterGroup (com.amazonaws.services.rds.model.DBParameterGroup)1 DescribeDBParameterGroupsRequest (com.amazonaws.services.rds.model.DescribeDBParameterGroupsRequest)1 DescribeDBParameterGroupsResult (com.amazonaws.services.rds.model.DescribeDBParameterGroupsResult)1 DescribeDBParametersRequest (com.amazonaws.services.rds.model.DescribeDBParametersRequest)1 DescribeDBParametersResult (com.amazonaws.services.rds.model.DescribeDBParametersResult)1 Parameter (com.amazonaws.services.rds.model.Parameter)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)1