private void addPermissions() { if (permissions != null && permissions.isEmpty() == false) { GetTopicAttributesResult result = client .getTopicAttributes(topicArn); AwsUtil.addPermissions(result.getAttributes(), permissions, new AwsUtil.AddPermissionHandler() { @Override public void execute(Permission p) { client.addPermission(new AddPermissionRequest() .withTopicArn(topicArn) .withLabel(p.getLabel()) .withAWSAccountIds(p.getAwsAccountIds()) .withActionNames(p.getActions())); } }); } }
@Test public void testGetSetTopicAttributes_shouldAddAndRespondAttributes() { mockSns(new MockParameters()); CreateTopicResult topicResult = sns.createTopic(new CreateTopicRequest().withName("attributefull-topic")); SetTopicAttributesResult setAttrResult = sns.setTopicAttributes(topicResult.getTopicArn(), "planet", "Omega 3"); assertNotNull(setAttrResult); GetTopicAttributesResult topicAttributes = sns.getTopicAttributes(new GetTopicAttributesRequest().withTopicArn(topicResult.getTopicArn())); assertEquals("verify added attribute is correct", "Omega 3", topicAttributes.getAttributes().get("planet")); sns.deleteTopic(topicResult.getTopicArn()); }
@Override public GetTopicAttributesResult getTopicAttributes(GetTopicAttributesRequest getTopicAttributesRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException(); }
@Override public boolean load(GetTopicAttributesRequest request, ResultCapture<GetTopicAttributesResult> extractor) { return resource.load(request, extractor); }
/** * Makes a call to the service to load this resource's attributes if they * are not loaded yet, and use a ResultCapture to retrieve the low-level * client response * The following request parameters will be populated from the data of this * <code>Topic</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>TopicArn</code></b> * - mapped from the <code>Arn</code> identifier. * </li> * </ul> * * <p> * * @return Returns {@code true} if the resource is not yet loaded when this * method was invoked, which indicates that a service call has been * made to retrieve the attributes. * @see GetTopicAttributesRequest */ boolean load(GetTopicAttributesRequest request, ResultCapture<GetTopicAttributesResult> extractor);