Skip to content

Commit

Permalink
Fix formatting (#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak authored Sep 22, 2024
1 parent 0fd457c commit 29f2c3c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void abortsWhenExplicitlyInvoked() throws IOException {
S3Client s3Client = mock(S3Client.class);

try (DiskBufferingS3OutputStream diskBufferingS3OutputStream = new DiskBufferingS3OutputStream(
new Location("bucket", "key"), s3Client, null)) {
new Location("bucket", "key"), s3Client, null)) {
diskBufferingS3OutputStream.write("hello".getBytes(StandardCharsets.UTF_8));
diskBufferingS3OutputStream.abort();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface SnsOperations {
* @param notification - the notification
*/
void sendNotification(String topic, SnsNotification<?> notification);

/**
* Checks if topic with given ARN exists.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ public void addChannelInterceptor(ChannelInterceptor channelInterceptor) {
public void sendNotification(String topic, SnsNotification<?> notification) {
this.convertAndSend(topic, notification.getPayload(), notification.getHeaders());
}

@Override
public boolean topicExists(String topicArn) {
Assert.notNull(topicArn, "topicArn must not be null");
try {
snsClient.getTopicAttributes(request -> request.topicArn(topicArn));
} catch (NotFoundException exception) {
}
catch (NotFoundException exception) {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import io.awspring.cloud.sns.core.SnsTemplate;
import io.awspring.cloud.sns.core.TopicNotFoundException;
import io.awspring.cloud.sns.core.TopicsListingTopicArnResolver;
import net.bytebuddy.utility.RandomString;

import java.util.HashMap;
import java.util.Map;
import net.bytebuddy.utility.RandomString;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
Expand Down Expand Up @@ -206,24 +205,24 @@ private static void createTopics() {
}
}
}

@Test
void shouldReturnFalseForNonExistingTopic() {
String nonExistentTopicArn = String.format("arn:aws:sns:us-east-1:000000000000:%s", RandomString.make());

boolean response = snsTemplate.topicExists(nonExistentTopicArn);

assertThat(response).isFalse();
}

@Test
void shouldReturnTrueForExistingTopic() {
String topicName = RandomString.make();
snsClient.createTopic(request -> request.name(topicName));
String topicArn = String.format("arn:aws:sns:us-east-1:000000000000:%s", topicName);

boolean response = snsTemplate.topicExists(topicArn);

assertThat(response).isTrue();
}

Expand Down

0 comments on commit 29f2c3c

Please sign in to comment.