Skip to content

Commit f9fc4a2

Browse files
Fix formatting (#1468)
1 parent a7a5344 commit f9fc4a2

File tree

8 files changed

+77
-119
lines changed

8 files changed

+77
-119
lines changed

spring-cloud-aws-dynamodb/src/test/java/io/awspring/cloud/dynamodb/LocalstackContainerTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025-2025 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,8 @@
2929

3030
/**
3131
* The base contract for JUnit tests based on the container for Localstack. The Testcontainers 'reuse' option must be
32-
* disabled, so, Ryuk container is started and will clean all the running containers from this test suite after JVM exit.
32+
* disabled, so, Ryuk container is started and will clean all the running containers from this test suite after JVM
33+
* exit.
3334
* <p>
3435
* Since the Localstack container instance is shared via static property, it is going to be started only once per JVM;
3536
* therefore, the target Docker container is reused automatically.
@@ -41,8 +42,8 @@
4142
@Testcontainers(disabledWithoutDocker = true)
4243
public interface LocalstackContainerTest {
4344

44-
LocalStackContainer LOCAL_STACK_CONTAINER =
45-
new LocalStackContainer(DockerImageName.parse("localstack/localstack:4.4.0"));
45+
LocalStackContainer LOCAL_STACK_CONTAINER = new LocalStackContainer(
46+
DockerImageName.parse("localstack/localstack:4.4.0"));
4647

4748
@BeforeAll
4849
static void startContainer() {
@@ -59,13 +60,13 @@ static DynamoDbAsyncClient dynamoDbAsyncClient() {
5960

6061
static AwsCredentialsProvider credentialsProvider() {
6162
return StaticCredentialsProvider.create(
62-
AwsBasicCredentials.create(LOCAL_STACK_CONTAINER.getAccessKey(), LOCAL_STACK_CONTAINER.getSecretKey()));
63+
AwsBasicCredentials.create(LOCAL_STACK_CONTAINER.getAccessKey(), LOCAL_STACK_CONTAINER.getSecretKey()));
6364
}
6465

6566
private static <B extends AwsClientBuilder<B, T>, T> T applyAwsClientOptions(B clientBuilder) {
6667
return clientBuilder.region(Region.of(LOCAL_STACK_CONTAINER.getRegion()))
67-
.credentialsProvider(credentialsProvider()).endpointOverride(LOCAL_STACK_CONTAINER.getEndpoint())
68-
.build();
68+
.credentialsProvider(credentialsProvider()).endpointOverride(LOCAL_STACK_CONTAINER.getEndpoint())
69+
.build();
6970
}
7071

7172
}

spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/integration/SqsMessageDrivenChannelAdapter.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025-2025 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,30 +13,26 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.awspring.cloud.sqs.integration;
1817

19-
import java.util.Arrays;
20-
import java.util.Collection;
21-
2218
import io.awspring.cloud.sqs.config.SqsMessageListenerContainerFactory;
2319
import io.awspring.cloud.sqs.listener.MessageListener;
2420
import io.awspring.cloud.sqs.listener.SqsContainerOptions;
2521
import io.awspring.cloud.sqs.listener.SqsMessageListenerContainer;
26-
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
27-
22+
import java.util.Arrays;
23+
import java.util.Collection;
2824
import org.springframework.integration.endpoint.MessageProducerSupport;
2925
import org.springframework.integration.support.management.IntegrationManagedResource;
3026
import org.springframework.jmx.export.annotation.ManagedAttribute;
3127
import org.springframework.jmx.export.annotation.ManagedResource;
3228
import org.springframework.messaging.Message;
3329
import org.springframework.messaging.support.GenericMessage;
3430
import org.springframework.util.Assert;
31+
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
3532

3633
/**
37-
* The {@link MessageProducerSupport} implementation for the Amazon SQS
38-
* {@code receiveMessage}. Works in 'listener' manner and delegates hard work to the
39-
* {@link SqsMessageListenerContainer}.
34+
* The {@link MessageProducerSupport} implementation for the Amazon SQS {@code receiveMessage}. Works in 'listener'
35+
* manner and delegates hard work to the {@link SqsMessageListenerContainer}.
4036
*
4137
* @author Artem Bilan
4238
* @author Patrick Fitzsimons
@@ -50,8 +46,8 @@
5046
@IntegrationManagedResource
5147
public class SqsMessageDrivenChannelAdapter extends MessageProducerSupport {
5248

53-
private final SqsMessageListenerContainerFactory.Builder<Object> sqsMessageListenerContainerFactory =
54-
SqsMessageListenerContainerFactory.builder();
49+
private final SqsMessageListenerContainerFactory.Builder<Object> sqsMessageListenerContainerFactory = SqsMessageListenerContainerFactory
50+
.builder();
5551

5652
private final String[] queues;
5753

@@ -73,8 +69,8 @@ public void setSqsContainerOptions(SqsContainerOptions sqsContainerOptions) {
7369
protected void onInit() {
7470
super.onInit();
7571
if (this.sqsContainerOptions != null) {
76-
this.sqsMessageListenerContainerFactory.configure(sqsContainerOptionsBuilder ->
77-
sqsContainerOptionsBuilder.fromBuilder(this.sqsContainerOptions.toBuilder()));
72+
this.sqsMessageListenerContainerFactory.configure(sqsContainerOptionsBuilder -> sqsContainerOptionsBuilder
73+
.fromBuilder(this.sqsContainerOptions.toBuilder()));
7874
}
7975
this.sqsMessageListenerContainerFactory.messageListener(new IntegrationMessageListener());
8076
this.listenerContainer = this.sqsMessageListenerContainerFactory.build().createContainer(this.queues);

spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/integration/SqsMessageHandler.java

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025-2025 the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,19 +13,16 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.awspring.cloud.sqs.integration;
1817

18+
import io.awspring.cloud.sqs.listener.SqsHeaders;
19+
import io.awspring.cloud.sqs.operations.SendResult;
20+
import io.awspring.cloud.sqs.operations.SqsAsyncOperations;
1921
import java.util.Collection;
2022
import java.util.concurrent.CompletableFuture;
2123
import java.util.concurrent.ExecutionException;
2224
import java.util.concurrent.TimeUnit;
2325
import java.util.concurrent.TimeoutException;
24-
25-
import io.awspring.cloud.sqs.listener.SqsHeaders;
26-
import io.awspring.cloud.sqs.operations.SendResult;
27-
import io.awspring.cloud.sqs.operations.SqsAsyncOperations;
28-
2926
import org.springframework.expression.EvaluationContext;
3027
import org.springframework.expression.Expression;
3128
import org.springframework.expression.common.LiteralExpression;
@@ -37,17 +34,16 @@
3734
import org.springframework.util.Assert;
3835

3936
/**
40-
* The {@link AbstractMessageProducingHandler} implementation for the Amazon SQS.
41-
* All the logic based on the {@link SqsAsyncOperations#sendAsync(String, Message)}
42-
* or {@link SqsAsyncOperations#sendManyAsync(String, Collection)} if the request message's payload
43-
* is a collection of {@link Message} instances.
37+
* The {@link AbstractMessageProducingHandler} implementation for the Amazon SQS. All the logic based on the
38+
* {@link SqsAsyncOperations#sendAsync(String, Message)} or {@link SqsAsyncOperations#sendManyAsync(String, Collection)}
39+
* if the request message's payload is a collection of {@link Message} instances.
4440
* <p>
45-
* All the SQS-specific message attributes have to be provided in the respective message headers
46-
* via {@link SqsHeaders.MessageSystemAttributes} constant values or with the {@link SqsAsyncOperations}.
41+
* All the SQS-specific message attributes have to be provided in the respective message headers via
42+
* {@link SqsHeaders.MessageSystemAttributes} constant values or with the {@link SqsAsyncOperations}.
4743
* <p>
48-
* This {@link AbstractMessageProducingHandler} produces a reply only in the {@link #isAsync()} mode.
49-
* For a single request message the {@link SendResult} is converted to the reply message with respective headers.
50-
* The {@link SendResult.Batch} is sent as a reply message's payload as is.
44+
* This {@link AbstractMessageProducingHandler} produces a reply only in the {@link #isAsync()} mode. For a single
45+
* request message the {@link SendResult} is converted to the reply message with respective headers. The
46+
* {@link SendResult.Batch} is sent as a reply message's payload as is.
5147
*
5248
* @author Artem Bilan
5349
*
@@ -120,21 +116,18 @@ protected void handleMessageInternal(Message<?> message) {
120116
Assert.notEmpty(collection, "The payload with a collection of messages must not be empty.");
121117
Object next = collection.iterator().next();
122118
Assert.isInstanceOf(Message.class, next,
123-
"The payload with a collection of messages must contain 'Message' instances only.");
119+
"The payload with a collection of messages must contain 'Message' instances only.");
124120
Collection<Message<Object>> messages = (Collection<Message<Object>>) collection;
125121

126122
resultFuture = this.sqsAsyncOperations.sendManyAsync(queueName, messages)
127-
.thenApply((batchResult) -> getMessageBuilderFactory().withPayload(batchResult).build());
123+
.thenApply((batchResult) -> getMessageBuilderFactory().withPayload(batchResult).build());
128124
}
129125
else {
130126
resultFuture = this.sqsAsyncOperations.sendAsync(queueName, message)
131-
.thenApply((sendResult) ->
132-
getMessageBuilderFactory()
133-
.fromMessage(sendResult.message())
134-
.setHeader(SqsHeaders.SQS_QUEUE_NAME_HEADER, sendResult.endpoint())
135-
.setHeader(SqsHeaders.MessageSystemAttributes.MESSAGE_ID, sendResult.messageId())
136-
.copyHeaders(sendResult.additionalInformation())
137-
.build());
127+
.thenApply((sendResult) -> getMessageBuilderFactory().fromMessage(sendResult.message())
128+
.setHeader(SqsHeaders.SQS_QUEUE_NAME_HEADER, sendResult.endpoint())
129+
.setHeader(SqsHeaders.MessageSystemAttributes.MESSAGE_ID, sendResult.messageId())
130+
.copyHeaders(sendResult.additionalInformation()).build());
138131
}
139132

140133
if (isAsync()) {

spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/listener/SqsHeaders.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.awspring.cloud.sqs.listener;
1817

1918
/**

spring-cloud-aws-sqs/src/test/java/io/awspring/cloud/sqs/integration/BaseSqsIntegrationTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.awspring.cloud.sqs.integration;
1817

1918
import io.awspring.cloud.sqs.CompletableFutures;

spring-cloud-aws-sqs/src/test/java/io/awspring/cloud/sqs/integration/SqsMessageDrivenChannelAdapterTests.java

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-present the original author or authors.
2+
* Copyright 2013-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,18 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.awspring.cloud.sqs.integration;
1817

19-
import java.util.Map;
18+
import static org.assertj.core.api.Assertions.assertThat;
2019

2120
import io.awspring.cloud.sqs.listener.SqsHeaders;
21+
import java.util.Map;
2222
import org.junit.jupiter.api.BeforeAll;
2323
import org.junit.jupiter.api.Test;
24-
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
25-
import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;
26-
import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequestEntry;
27-
2824
import org.springframework.beans.factory.annotation.Autowired;
2925
import org.springframework.context.annotation.Bean;
3026
import org.springframework.context.annotation.Configuration;
@@ -34,8 +30,9 @@
3430
import org.springframework.messaging.PollableChannel;
3531
import org.springframework.test.annotation.DirtiesContext;
3632
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
37-
38-
import static org.assertj.core.api.Assertions.assertThat;
33+
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
34+
import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;
35+
import software.amazon.awssdk.services.sqs.model.SendMessageBatchRequestEntry;
3936

4037
/**
4138
* @author Artem Bilan
@@ -59,25 +56,14 @@ static void setup() {
5956

6057
@Test
6158
void sqsMessageDrivenChannelAdapter() {
62-
Map<String, MessageAttributeValue> attributes =
63-
Map.of("someAttribute",
64-
MessageAttributeValue.builder()
65-
.stringValue("someValue")
66-
.dataType("String")
67-
.build());
68-
69-
AMAZON_SQS.sendMessageBatch(request ->
70-
request.queueUrl(testQueueUrl)
71-
.entries(SendMessageBatchRequestEntry.builder()
72-
.messageBody("messageContent")
73-
.id("messageContent_id")
74-
.messageAttributes(attributes)
75-
.build(),
76-
SendMessageBatchRequestEntry.builder()
77-
.messageBody("messageContent2")
78-
.id("messageContent2_id")
79-
.messageAttributes(attributes)
80-
.build()));
59+
Map<String, MessageAttributeValue> attributes = Map.of("someAttribute",
60+
MessageAttributeValue.builder().stringValue("someValue").dataType("String").build());
61+
62+
AMAZON_SQS.sendMessageBatch(request -> request.queueUrl(testQueueUrl).entries(
63+
SendMessageBatchRequestEntry.builder().messageBody("messageContent").id("messageContent_id")
64+
.messageAttributes(attributes).build(),
65+
SendMessageBatchRequestEntry.builder().messageBody("messageContent2").id("messageContent2_id")
66+
.messageAttributes(attributes).build()));
8167

8268
org.springframework.messaging.Message<?> receive = this.inputChannel.receive(10000);
8369
assertThat(receive).isNotNull();

0 commit comments

Comments
 (0)