Java 类com.amazonaws.services.sns.model.ListTopicsRequest 实例源码

项目:spring-cloud-aws    文件:DynamicTopicDestinationResolverTest.java   
@Test
public void resolveDestination_withExistentTopic_returnsTopicArnFoundWhileListingTopic() throws Exception {
    // Arrange
    String topicArn = "arn:aws:sns:eu-west:123456789012:test";

    AmazonSNS sns = mock(AmazonSNS.class);
    when(sns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult().withTopics(new Topic().withTopicArn(topicArn)));

    DynamicTopicDestinationResolver resolver = new DynamicTopicDestinationResolver(sns);

    // Act
    String resolvedDestinationName = resolver.resolveDestination("test");

    // Assert
    assertEquals(topicArn, resolvedDestinationName);
}
项目:spring-cloud-aws    文件:DynamicTopicDestinationResolverTest.java   
@Test
public void resolveDestination_withExistentTopicAndMarker_returnsTopicArnFoundWhileListingTopic() throws Exception {
    // Arrange

    AmazonSNS sns = mock(AmazonSNS.class);
    when(sns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult().withNextToken("mark"));

    String topicArn = "arn:aws:sns:eu-west:123456789012:test";
    when(sns.listTopics(new ListTopicsRequest("mark"))).thenReturn(new ListTopicsResult().withTopics(new Topic().withTopicArn(topicArn)));

    DynamicTopicDestinationResolver resolver = new DynamicTopicDestinationResolver(sns);

    // Act
    String resolvedDestinationName = resolver.resolveDestination("test");

    // Assert
    assertEquals(topicArn, resolvedDestinationName);
}
项目:spring-cloud-aws    文件:DynamicTopicDestinationResolverTest.java   
@Test
public void resolveDestination_withResourceIdResolver_shouldCallIt() throws Exception {
    // Arrange
    String physicalTopicName = "arn:aws:sns:eu-west:123456789012:myTopic";
    String logicalTopicName = "myTopic";

    ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class);
    when(resourceIdResolver.resolveToPhysicalResourceId(logicalTopicName)).thenReturn(physicalTopicName);

    AmazonSNS sns = mock(AmazonSNS.class);
    when(sns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult().withTopics(new Topic().withTopicArn(physicalTopicName)));

    DynamicTopicDestinationResolver resolver = new DynamicTopicDestinationResolver(sns, resourceIdResolver);

    // Assert
    String resolvedDestinationName = resolver.resolveDestination(logicalTopicName);

    // Assert
    assertEquals(physicalTopicName, resolvedDestinationName);
}
项目:spring-cloud-aws    文件:NotificationMessagingTemplateTest.java   
@Test
public void send_validTextMessage_usesTopicChannel() throws Exception {
    // Arrange
    AmazonSNS amazonSns = mock(AmazonSNS.class);
    NotificationMessagingTemplate notificationMessagingTemplate = new NotificationMessagingTemplate(amazonSns);
    String physicalTopicName = "arn:aws:sns:eu-west:123456789012:test";
    when(amazonSns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult().withTopics(new Topic().withTopicArn(physicalTopicName)));
    notificationMessagingTemplate.setDefaultDestinationName(physicalTopicName);

    // Act
    notificationMessagingTemplate.send(MessageBuilder.withPayload("Message content").build());

    // Assert
    verify(amazonSns).publish(new PublishRequest(physicalTopicName,
            "Message content", null).withMessageAttributes(isNotNull()));
}
项目:aws-sdk-java-resources    文件:SNSImpl.java   
@Override
public TopicCollection getTopics(ListTopicsRequest request) {
    ResourceCollectionImpl result = service.getCollection("Topics",
            request);

    if (result == null) return null;
    return new TopicCollectionImpl(result);
}
项目:spring-cloud-aws    文件:DynamicTopicDestinationResolver.java   
private String getTopicResourceName(String marker, String topicName) {
    ListTopicsResult listTopicsResult = this.amazonSns.listTopics(new ListTopicsRequest(marker));
    for (Topic topic : listTopicsResult.getTopics()) {
        AmazonResourceName resourceName = AmazonResourceName.fromString(topic.getTopicArn());
        if (resourceName.getResourceType().equals(topicName)) {
            return topic.getTopicArn();
        }
    }

    if (StringUtils.hasText(listTopicsResult.getNextToken())) {
        return getTopicResourceName(listTopicsResult.getNextToken(), topicName);
    } else {
        throw new IllegalArgumentException("No topic found for name :'" + topicName + "'");
    }
}
项目:spring-cloud-aws    文件:DynamicTopicDestinationResolverTest.java   
@Test
public void resolveDestination_withNonExistentTopicAndWithoutMarkerReturnedOnListTopics_shouldThrowIllegalArgumentException() throws Exception {
    // Arrange
    this.expectedException.expect(IllegalArgumentException.class);
    this.expectedException.expectMessage("No topic found for name :'test'");

    AmazonSNS sns = mock(AmazonSNS.class);
    when(sns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult());

    DynamicTopicDestinationResolver resolver = new DynamicTopicDestinationResolver(sns);

    // Act
    resolver.resolveDestination("test");
}
项目:spring-cloud-aws    文件:DynamicTopicDestinationResolverTest.java   
@Test
public void resolveDestination_withNonExistentTopicAndWithMarkerReturnedOnListTopics_shouldCallListMultipleTimeWithMarkerAndThrowIllegalArgumentException() throws Exception {
    // Arrange
    this.expectedException.expect(IllegalArgumentException.class);
    this.expectedException.expectMessage("No topic found for name :'test'");

    AmazonSNS sns = mock(AmazonSNS.class);
    when(sns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult().withNextToken("foo"));
    when(sns.listTopics(new ListTopicsRequest("foo"))).thenReturn(new ListTopicsResult());

    DynamicTopicDestinationResolver resolver = new DynamicTopicDestinationResolver(sns);

    // Act
    resolver.resolveDestination("test");
}
项目:spring-cloud-aws    文件:NotificationMessagingTemplateTest.java   
@Test
public void convertAndSend_withDestinationPayloadAndSubject_shouldSetSubject() throws Exception {
    // Arrange
    AmazonSNS amazonSns = mock(AmazonSNS.class);
    NotificationMessagingTemplate notificationMessagingTemplate = new NotificationMessagingTemplate(amazonSns);
    String physicalTopicName = "arn:aws:sns:eu-west:123456789012:test";
    when(amazonSns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult().withTopics(new Topic().withTopicArn(physicalTopicName)));

    // Act
    notificationMessagingTemplate.sendNotification(physicalTopicName, "My message", "My subject");

    // Assert
    verify(amazonSns).publish(new PublishRequest(physicalTopicName, "My message", "My subject").withMessageAttributes(isNotNull()));
}
项目:spring-cloud-aws    文件:NotificationMessagingTemplateTest.java   
@Test
public void convertAndSend_withPayloadAndSubject_shouldSetSubject() throws Exception {
    // Arrange
    AmazonSNS amazonSns = mock(AmazonSNS.class);
    NotificationMessagingTemplate notificationMessagingTemplate = new NotificationMessagingTemplate(amazonSns);
    String physicalTopicName = "arn:aws:sns:eu-west:123456789012:test";
    when(amazonSns.listTopics(new ListTopicsRequest(null))).thenReturn(new ListTopicsResult().withTopics(new Topic().withTopicArn(physicalTopicName)));
    notificationMessagingTemplate.setDefaultDestinationName(physicalTopicName);

    // Act
    notificationMessagingTemplate.sendNotification("My message", "My subject");

    // Assert
    verify(amazonSns).publish(new PublishRequest(physicalTopicName, "My message", "My subject").withMessageAttributes(isNotNull()));
}
项目:Camel    文件:AmazonSNSClientMock.java   
@Override
public ListTopicsResult listTopics(ListTopicsRequest listTopicsRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException();
}
项目:aws-sdk-java-resources    文件:SNSImpl.java   
@Override
public TopicCollection getTopics() {
    return getTopics((ListTopicsRequest)null);
}
项目:awslocal    文件:InMemorySNS.java   
@Override
public ListTopicsResult listTopics(ListTopicsRequest listTopicsRequest) throws AmazonClientException {
    return listTopics();
}
项目:aws-sdk-java-resources    文件:SNS.java   
/**
 * Retrieves the Topics collection referenced by this resource.
 */
TopicCollection getTopics(ListTopicsRequest request);