• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ListTopicsResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.sns.model.ListTopicsResult的典型用法代码示例。如果您正苦于以下问题:Java ListTopicsResult类的具体用法?Java ListTopicsResult怎么用?Java ListTopicsResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ListTopicsResult类属于com.amazonaws.services.sns.model包,在下文中一共展示了ListTopicsResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCreateListDeleteTopic_shouldCreateReturnAndDelete

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Test
public void testCreateListDeleteTopic_shouldCreateReturnAndDelete() {
  mockSns(new MockParameters());
  
  ListTopicsResult listTopicResultBefore = sns.listTopics();
  assertEquals("topic list should contain zero items before insert",0,listTopicResultBefore.getTopics().size());
  
  CreateTopicRequest create = new CreateTopicRequest()
      .withName("major-topic");
  CreateTopicResult createResult = sns.createTopic(create);
  String topicArn = createResult.getTopicArn();
  assertNotNull("verify returned topic ARN", topicArn);
  
  ListTopicsResult listTopicResult = sns.listTopics();
  assertEquals("after insert topic list should contain 1 item",1,listTopicResult.getTopics().size());
  assertEquals("after insert topic list should contain before inserted topic arn", topicArn, 
      listTopicResult.getTopics().get(0).getTopicArn());
  
  DeleteTopicResult deleteResult = sns.deleteTopic(topicArn);
  assertNotNull(deleteResult);
  
  ListTopicsResult listTopicsAfterDeletion = sns.listTopics();
  assertEquals("topic list should contain zero items after deletion",0,listTopicsAfterDeletion.getTopics().size());
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:25,代码来源:MockSnsTest.java


示例2: getOrCreateNotification

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
/**
 * 
 * @param email
 * @return
 */
public String getOrCreateNotification(String email) {
    String ret = null;
    String topicName = getTopicName(email);
    String nextToken = null;
    do {
        ListTopicsResult listTopics = asyncSnsClient.listTopics(nextToken);
        List<Topic> topics = listTopics.getTopics();
        for (Topic s : topics) {
            if (s.getTopicArn().endsWith(topicName)) {
                ret = s.getTopicArn();
                break;
            }
        }
        nextToken = listTopics.getNextToken();
    } while (ret == null && nextToken != null);
    if (ret == null) {
        // create the topic and the subscription
        CreateTopicResult topic = asyncSnsClient.createTopic(topicName);
        SubscribeRequest req = new SubscribeRequest(topic.getTopicArn(), "email", email);
        asyncSnsClient.subscribeAsync(req);
        ret = topic.getTopicArn();
    }

    return ret;
}
 
开发者ID:intuit,项目名称:Tank,代码行数:31,代码来源:CloudwatchInstance.java


示例3: shouldCreateSnsTopicResource_withName

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Test
public void shouldCreateSnsTopicResource_withName() throws Exception {
    // Given
    final String name = randomString();
    final String topicArn = topicArnForName(name);
    final List<Topic> topics = Arrays.asList(randomTopic(), randomTopic(), topicForArn(topicArn), randomTopic());
    final ListTopicsResult mockListTopicsResult = mock(ListTopicsResult.class);
    when(mockListTopicsResult.getTopics()).thenReturn(topics);
    when(mockListTopicsResult.getNextToken()).thenReturn(null);
    final String nextToken = null;
    when(mockAmazonSnsClient.listTopics(nextToken)).thenReturn(mockListTopicsResult);
    final SnsTopicResource mockSnsTopicResource = mock(SnsTopicResource.class);
    whenNew(SnsTopicResource.class).withArguments(name, topicArn, mockAmazonSnsClient)
            .thenReturn(mockSnsTopicResource);

    // When
    final SnsTopicResource result = factory.createSnsTopicResource(name);

    // Then
    assertSame(mockSnsTopicResource, result);
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:22,代码来源:DefaultSnsTopicResourceFactoryTest.java


示例4: resolveDestination_withExistentTopic_returnsTopicArnFoundWhileListingTopic

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:17,代码来源:DynamicTopicDestinationResolverTest.java


示例5: resolveDestination_withExistentTopicAndMarker_returnsTopicArnFoundWhileListingTopic

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:19,代码来源:DynamicTopicDestinationResolverTest.java


示例6: resolveDestination_withResourceIdResolver_shouldCallIt

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:21,代码来源:DynamicTopicDestinationResolverTest.java


示例7: send_validTextMessage_usesTopicChannel

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@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()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:17,代码来源:NotificationMessagingTemplateTest.java


示例8: getTopicARN

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
public String getTopicARN() {
	try {
		if (topicANR.isEmpty()) {
			ListTopicsResult topics = snsClient.listTopics();
			for(Topic topic : topics.getTopics()) {
				String foundArn = topic.getTopicArn();
				if (foundArn.contains(TOPIC_NAME)) {
					logger.info("Found notification topic for SNS, ARN is: " + foundArn);
					topicANR =  foundArn;
					break;
				}
			}
		}
		if (topicANR.isEmpty()) {
			logger.info("Did not find notification topic for SNS, to receive updates create topic: " + TOPIC_NAME);
		}
		return topicANR;
	} 
	catch (AuthorizationErrorException authException) {
		logger.error("Did not send SNS notification. You may need to update permissions for user via IAM. Exception was " + authException);
		return "";
	}
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:24,代码来源:SNSNotificationSender.java


示例9: listTopicsFromEmptyRepository

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Test
public void listTopicsFromEmptyRepository() {
    final ListTopicsResult result = sns.listTopics();

    assertThat(result.getNextToken()).isNull();
    assertThat(result.getTopics()).isEmpty();
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:8,代码来源:AmazonSNSFakeListTopicsTest.java


示例10: listSingleTopic

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Test
public void listSingleTopic() {
    sns.createTopic("test");
    final ListTopicsResult result = sns.listTopics();

    assertThat(result.getNextToken()).isNull();
    assertThat(arnValues(result.getTopics())).containsExactly("arn:aws:sns:us-east-1:12345:test");
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:9,代码来源:AmazonSNSFakeListTopicsTest.java


示例11: listMultiple

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Test
public void listMultiple() {
    final String[] topics = new String[5];
    for (int i = 0; i < 5; i++)
        topics[i] = sns.createTopic("topic" + i).getTopicArn();
    final ListTopicsResult result = sns.listTopics();

    assertThat(result.getNextToken()).isNull();
    assertThat(arnValues(result.getTopics())).containsExactly(topics);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:11,代码来源:AmazonSNSFakeListTopicsTest.java


示例12: topicsAreReturnedInChunksOf100

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Test
public void topicsAreReturnedInChunksOf100() {
    for (int i = 0; i < 120; i++)
        sns.createTopic("topic" + i);
    ListTopicsResult result = sns.listTopics();

    final String token = result.getNextToken();
    assertThat(token).isNotNull();
    assertThat(arnValues(result.getTopics()))
            .hasSize(100)
            .contains(
                    "arn:aws:sns:us-east-1:12345:topic0",
                    "arn:aws:sns:us-east-1:12345:topic1",
                    "arn:aws:sns:us-east-1:12345:topic10",
                    "arn:aws:sns:us-east-1:12345:topic100",
                    "arn:aws:sns:us-east-1:12345:topic8",
                    "arn:aws:sns:us-east-1:12345:topic80")
            .doesNotContain(
                    "arn:aws:sns:us-east-1:12345:topic9");

    result = sns.listTopics(token);
    assertThat(result.getNextToken()).isNull();
    assertThat(arnValues(result.getTopics()))
            .hasSize(20)
            .contains(
                    "arn:aws:sns:us-east-1:12345:topic81",
                    "arn:aws:sns:us-east-1:12345:topic9",
                    "arn:aws:sns:us-east-1:12345:topic90",
                    "arn:aws:sns:us-east-1:12345:topic99")
            .doesNotContain(
                    "arn:aws:sns:us-east-1:12345:topic120");
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:33,代码来源:AmazonSNSFakeListTopicsTest.java


示例13: topicsShouldBeReturnedInOrder

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Test
public void topicsShouldBeReturnedInOrder() {
    final String[] topics = new String[4];
    topics[1] = sns.createTopic("10").getTopicArn();
    topics[0] = sns.createTopic("1").getTopicArn();
    topics[3] = sns.createTopic("8").getTopicArn();
    topics[2] = sns.createTopic("17").getTopicArn();
    final ListTopicsResult result = sns.listTopics();

    assertThat(result.getNextToken()).isNull();
    assertThat(arnValues(result.getTopics())).containsExactly(topics);
}
 
开发者ID:OpenG,项目名称:aws-java-sdk,代码行数:13,代码来源:AmazonSNSFakeListTopicsTest.java


示例14: topicArnForName

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
private String topicArnForName(final String name) {
    String nextToken = null;
    String topicArn = null;
    while (topicArn == null) {
        final ListTopicsResult listTopicsResult = amazonSnsClient.listTopics(nextToken);
        topicArn = topicArnForNameInTopics(name, listTopicsResult.getTopics());
        nextToken = listTopicsResult.getNextToken();
        if (nextToken == null) {
            break;
        }
    }
    return topicArn;
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:14,代码来源:DefaultSnsTopicResourceFactory.java


示例15: getTopicResourceName

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
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 + "'");
    }
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:16,代码来源:DynamicTopicDestinationResolver.java


示例16: mock

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@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");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:15,代码来源:DynamicTopicDestinationResolverTest.java


示例17: convertAndSend_withDestinationPayloadAndSubject_shouldSetSubject

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@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()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:15,代码来源:NotificationMessagingTemplateTest.java


示例18: convertAndSend_withPayloadAndSubject_shouldSetSubject

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@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()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:16,代码来源:NotificationMessagingTemplateTest.java


示例19: listTopics

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Override
public ListTopicsResult listTopics() throws AmazonClientException {
    return new ListTopicsResult().
            withTopics(FluentIterable.
                    from(_subscriptionsForTopic.keySet()).
                    transform(NEW_TOPIC).
                    toList());
}
 
开发者ID:bazaarvoice,项目名称:awslocal,代码行数:9,代码来源:InMemorySNS.java


示例20: listTopics

import com.amazonaws.services.sns.model.ListTopicsResult; //导入依赖的package包/类
@Override
public ListTopicsResult listTopics(ListTopicsRequest listTopicsRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:AmazonSNSClientMock.java



注:本文中的com.amazonaws.services.sns.model.ListTopicsResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DwcTerm类代码示例发布时间:2022-05-22
下一篇:
Java ReadTimeoutException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap