Skip to content

Commit 1b51841

Browse files
Fix formatting (#1408)
1 parent b1e90e3 commit 1b51841

File tree

13 files changed

+303
-351
lines changed

13 files changed

+303
-351
lines changed

spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/ObjectMetadataTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ void canBeAppliedToPutObjectRequest() {
5555
objectMetadata.apply(builder);
5656

5757
assertThat(builder).usingRecursiveComparison()
58-
.ignoringFields("awsRequestOverrideConfig", "checksumCRC32C", "checksumCRC64NVME", "checksumSHA1", "checksumSHA256", "key",
59-
"contentMD5", "bucket", "checksumCRC32", "contentLength", "ifNoneMatch", "ifMatch",
60-
"writeOffsetBytes")
58+
.ignoringFields("awsRequestOverrideConfig", "checksumCRC32C", "checksumCRC64NVME", "checksumSHA1",
59+
"checksumSHA256", "key", "contentMD5", "bucket", "checksumCRC32", "contentLength",
60+
"ifNoneMatch", "ifMatch", "writeOffsetBytes")
6161
.isEqualTo(objectMetadata);
6262
}
6363

spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/support/observation/AbstractListenerObservation.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,16 @@ public KeyValues getLowCardinalityKeyValues(ContextType context) {
5050
.withValue(context.getSourceName()),
5151
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_SOURCE_KIND
5252
.withValue(getSourceKind()))
53-
.and(getSpecificLowCardinalityKeyValues(context))
54-
.and(getCustomLowCardinalityKeyValues(context));
53+
.and(getSpecificLowCardinalityKeyValues(context)).and(getCustomLowCardinalityKeyValues(context));
5554
}
5655

5756
protected KeyValues getSpecificLowCardinalityKeyValues(ContextType context) {
5857
return KeyValues.empty();
5958
}
6059

6160
/**
62-
* Return custom low cardinality key values for the observation. This method is intended to
63-
* be overridden by subclasses to add custom low cardinality tags to the observation.
61+
* Return custom low cardinality key values for the observation. This method is intended to be overridden by
62+
* subclasses to add custom low cardinality tags to the observation.
6463
*
6564
* @param context the context for which to get key values.
6665
* @return key values to add to the observation, empty by default.
@@ -81,8 +80,8 @@ protected KeyValues getSpecificHighCardinalityKeyValues(ContextType context) {
8180
}
8281

8382
/**
84-
* Return custom high cardinality key values for the observation. This method is intended to
85-
* be overridden by subclasses to add custom high cardinality tags to the observation.
83+
* Return custom high cardinality key values for the observation. This method is intended to be overridden by
84+
* subclasses to add custom high cardinality tags to the observation.
8685
*
8786
* @param context the context for which to get key values.
8887
* @return key values to add to the observation, empty by default.

spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/support/observation/AbstractTemplateObservation.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import io.micrometer.observation.transport.SenderContext;
2525
import java.util.HashMap;
2626
import java.util.Map;
27-
2827
import org.springframework.lang.NonNull;
2928
import org.springframework.messaging.Message;
3029
import org.springframework.util.Assert;
@@ -62,8 +61,8 @@ protected KeyValues getSpecificLowCardinalityKeyValues(ContextType context) {
6261
}
6362

6463
/**
65-
* Return custom low cardinality key values for the observation. This method is intended to
66-
* be overridden by subclasses to add custom low cardinality tags to the observation.
64+
* Return custom low cardinality key values for the observation. This method is intended to be overridden by
65+
* subclasses to add custom low cardinality tags to the observation.
6766
*
6867
* @param context the context for which to get key values.
6968
* @return key values to add to the observation, empty by default.
@@ -75,25 +74,23 @@ protected KeyValues getCustomLowCardinalityKeyValues(ContextType context) {
7574
@Override
7675
@NonNull
7776
public KeyValues getHighCardinalityKeyValues(@NonNull ContextType context) {
78-
return getMessageIdKeyValue(context)
79-
.and(getSpecificHighCardinalityKeyValues(context))
80-
.and(getCustomHighCardinalityKeyValues(context));
77+
return getMessageIdKeyValue(context).and(getSpecificHighCardinalityKeyValues(context))
78+
.and(getCustomHighCardinalityKeyValues(context));
8179
}
8280

8381
private KeyValues getMessageIdKeyValue(ContextType context) {
8482
String messageId = context.getMessageId();
85-
return messageId != null ? KeyValues
86-
.of(Documentation.HighCardinalityTags.MESSAGE_ID
87-
.withValue(messageId)) : KeyValues.empty();
83+
return messageId != null ? KeyValues.of(Documentation.HighCardinalityTags.MESSAGE_ID.withValue(messageId))
84+
: KeyValues.empty();
8885
}
8986

9087
protected KeyValues getSpecificHighCardinalityKeyValues(ContextType context) {
9188
return KeyValues.empty();
9289
}
9390

9491
/**
95-
* Return custom high cardinality key values for the observation. This method is intended to
96-
* be overridden by subclasses to add custom high cardinality tags to the observation.
92+
* Return custom high cardinality key values for the observation. This method is intended to be overridden by
93+
* subclasses to add custom high cardinality tags to the observation.
9794
*
9895
* @param context the context for which to get key values.
9996
* @return key values to add to the observation, empty by default.
@@ -263,7 +260,8 @@ protected Context(Message<?> message, String destinationName) {
263260
}
264261

265262
private static boolean isAllowedKey(String key) {
266-
return BAGGAGE_KEY.equals(key) || TRACEPARENT_KEY.equals(key) || TRACESTATE_KEY.equals(key) || B3_KEY.equals(key);
263+
return BAGGAGE_KEY.equals(key) || TRACEPARENT_KEY.equals(key) || TRACESTATE_KEY.equals(key)
264+
|| B3_KEY.equals(key);
267265
}
268266

269267
/**

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,8 @@ void observesMessageFifo() throws Exception {
268268
SqsHeaders.MessageSystemAttributes.SQS_MESSAGE_DEDUPLICATION_ID_HEADER);
269269
logger.debug("Sent message to queue {} with messageBody {}", OBSERVES_MESSAGE_FIFO_QUEUE_NAME, messageBody);
270270
assertThat(latchContainer.observesFifoMessageLatch.await(10, TimeUnit.MINUTES)).isTrue();
271-
await()
272-
.atMost(10, TimeUnit.SECONDS)
273-
.untilAsserted(() ->
274-
TestObservationRegistryAssert.then(observationRegistry).hasNumberOfObservationsEqualTo(3)
275-
.hasHandledContextsThatSatisfy(contexts -> {
271+
await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> TestObservationRegistryAssert.then(observationRegistry)
272+
.hasNumberOfObservationsEqualTo(3).hasHandledContextsThatSatisfy(contexts -> {
276273
ObservationContextAssert.then(contexts.get(0)).hasNameEqualTo("spring.aws.sqs.template")
277274
.isInstanceOf(SqsTemplateObservation.Context.class)
278275
.hasContextualNameEqualTo(OBSERVES_MESSAGE_FIFO_QUEUE_NAME + " send")
@@ -338,8 +335,7 @@ void observesMessageFifo() throws Exception {
338335
ObservationContextAssert.then(contexts.get(2)).hasNameEqualTo("listener.process")
339336
.hasParentObservationContextMatching(
340337
contextView -> contextView.getName().equals("spring.aws.sqs.listener"));
341-
})
342-
);
338+
}));
343339
}
344340

345341
@Test
@@ -730,20 +726,17 @@ public MessagesContainer messagesContainer() {
730726
}
731727

732728
@Bean
733-
public SqsMessageListenerContainerFactory<String> observationSqsListenerContainerFactory(ObservationRegistry observationRegistry) {
729+
public SqsMessageListenerContainerFactory<String> observationSqsListenerContainerFactory(
730+
ObservationRegistry observationRegistry) {
734731
SqsMessageListenerContainerFactory<String> factory = new SqsMessageListenerContainerFactory<>();
735-
factory.configure(options -> options
736-
.maxConcurrentMessages(10)
737-
.acknowledgementThreshold(10)
738-
.acknowledgementOrdering(AcknowledgementOrdering.ORDERED_BY_GROUP)
739-
.acknowledgementInterval(Duration.ofSeconds(1))
740-
.observationRegistry(observationRegistry)
741-
);
732+
factory.configure(options -> options.maxConcurrentMessages(10).acknowledgementThreshold(10)
733+
.acknowledgementOrdering(AcknowledgementOrdering.ORDERED_BY_GROUP)
734+
.acknowledgementInterval(Duration.ofSeconds(1)).observationRegistry(observationRegistry));
742735
factory.setSqsAsyncClientSupplier(BaseSqsIntegrationTest::createHighThroughputAsyncClient);
743736
return factory;
744737
}
745738

746-
// @formatter:off
739+
// @formatter:off
747740
@Bean
748741
public SqsMessageListenerContainerFactory<String> defaultSqsListenerContainerFactory() {
749742
SqsMessageListenerContainerFactory<String> factory = new SqsMessageListenerContainerFactory<>();

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

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
import java.util.concurrent.atomic.AtomicBoolean;
7575
import java.util.stream.Collectors;
7676
import java.util.stream.IntStream;
77-
7877
import org.jetbrains.annotations.NotNull;
7978
import org.junit.jupiter.api.BeforeAll;
8079
import org.junit.jupiter.api.Test;
@@ -205,75 +204,80 @@ void receivesMessage() throws Exception {
205204
void observesMessage() throws Exception {
206205
String messageBody = "observesMessage-payload";
207206
SendResult<Object> sendResult = sqsTemplate
208-
.send(to -> to.queue(OBSERVES_MESSAGE_QUEUE_NAME).payload(messageBody));
207+
.send(to -> to.queue(OBSERVES_MESSAGE_QUEUE_NAME).payload(messageBody));
209208
logger.debug("Sent message to queue {} with messageBody {}", OBSERVES_MESSAGE_QUEUE_NAME, messageBody);
210209
assertThat(latchContainer.observesMessageLatch.await(10, TimeUnit.SECONDS)).isTrue();
211-
await()
212-
.atMost(10, TimeUnit.SECONDS)
213-
.untilAsserted(() ->
214-
TestObservationRegistryAssert.then(observationRegistry)
215-
.hasHandledContextsThatSatisfy(contexts -> {
216-
ObservationContextAssert.then(getContextWithContextualNameEqualTo(contexts, "observes_message_test_queue send"))
210+
await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> TestObservationRegistryAssert.then(observationRegistry)
211+
.hasHandledContextsThatSatisfy(contexts -> {
212+
ObservationContextAssert
213+
.then(getContextWithContextualNameEqualTo(contexts, "observes_message_test_queue send"))
217214
.hasNameEqualTo("spring.aws.sqs.template")
218215
.isInstanceOf(SqsTemplateObservation.Context.class)
219216
.hasLowCardinalityKeyValue(
220-
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_OPERATION
221-
.asString(),
222-
"publish")
217+
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_OPERATION
218+
.asString(),
219+
"publish")
223220
.hasLowCardinalityKeyValue(
224-
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_DESTINATION_NAME
225-
.asString(),
226-
OBSERVES_MESSAGE_QUEUE_NAME)
221+
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_DESTINATION_NAME
222+
.asString(),
223+
OBSERVES_MESSAGE_QUEUE_NAME)
227224
.hasLowCardinalityKeyValue(
228-
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_DESTINATION_KIND
229-
.asString(),
230-
"queue")
225+
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_DESTINATION_KIND
226+
.asString(),
227+
"queue")
231228
.hasLowCardinalityKeyValue(
232-
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_SYSTEM
233-
.asString(),
234-
"sqs")
229+
AbstractTemplateObservation.Documentation.LowCardinalityTags.MESSAGING_SYSTEM
230+
.asString(),
231+
"sqs")
235232
.hasHighCardinalityKeyValue(
236-
AbstractTemplateObservation.Documentation.HighCardinalityTags.MESSAGE_ID.asString(),
237-
sendResult.messageId().toString())
233+
AbstractTemplateObservation.Documentation.HighCardinalityTags.MESSAGE_ID.asString(),
234+
sendResult.messageId().toString())
238235
.doesNotHaveParentObservation();
239-
ObservationContextAssert.then(getContextWithContextualNameEqualTo(contexts, "observes_message_test_queue receive"))
236+
ObservationContextAssert
237+
.then(getContextWithContextualNameEqualTo(contexts, "observes_message_test_queue receive"))
240238
.hasNameEqualTo("spring.aws.sqs.listener")
241239
.isInstanceOf(SqsListenerObservation.Context.class)
242240
.hasLowCardinalityKeyValue(
243-
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_OPERATION
244-
.asString(),
245-
"receive")
241+
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_OPERATION
242+
.asString(),
243+
"receive")
246244
.hasLowCardinalityKeyValue(
247-
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_SOURCE_NAME
248-
.asString(),
249-
"observes_message_test_queue")
245+
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_SOURCE_NAME
246+
.asString(),
247+
"observes_message_test_queue")
250248
.hasLowCardinalityKeyValue(
251-
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_SOURCE_KIND
252-
.asString(),
253-
"queue")
249+
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_SOURCE_KIND
250+
.asString(),
251+
"queue")
254252
.hasLowCardinalityKeyValue(
255-
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_SYSTEM
256-
.asString(),
257-
"sqs")
253+
AbstractListenerObservation.Documentation.LowCardinalityTags.MESSAGING_SYSTEM
254+
.asString(),
255+
"sqs")
258256
.hasHighCardinalityKeyValue(
259-
AbstractListenerObservation.Documentation.HighCardinalityTags.MESSAGE_ID.asString(),
260-
sendResult.messageId().toString())
257+
AbstractListenerObservation.Documentation.HighCardinalityTags.MESSAGE_ID.asString(),
258+
sendResult.messageId().toString())
261259
.doesNotHaveHighCardinalityKeyValueWithKey(
262-
SqsListenerObservation.Documentation.HighCardinalityTags.MESSAGE_GROUP_ID
263-
.asString())
260+
SqsListenerObservation.Documentation.HighCardinalityTags.MESSAGE_GROUP_ID
261+
.asString())
264262
.doesNotHaveParentObservation();
265-
ObservationContextAssert.then(getContextWithName(contexts, "listener.process"))
263+
ObservationContextAssert.then(getContextWithName(contexts, "listener.process"))
266264
.hasParentObservationContextMatching(
267-
contextView -> contextView.getName().equals("spring.aws.sqs.listener"));
268-
}));
265+
contextView -> contextView.getName().equals("spring.aws.sqs.listener"));
266+
}));
269267
}
270268

271269
private Observation.@NotNull Context getContextWithName(List<Observation.Context> contexts, String name) {
272-
return contexts.stream().filter(context -> context.getName().equals(name)).findFirst().orElseThrow(() -> new AssertionError("Could not find context with name " + name));
270+
return contexts.stream().filter(context -> context.getName().equals(name)).findFirst()
271+
.orElseThrow(() -> new AssertionError("Could not find context with name " + name));
273272
}
274273

275-
private Observation.@NotNull Context getContextWithContextualNameEqualTo(List<Observation.Context> contexts, String contextualName) {
276-
return contexts.stream().filter(context -> context.getContextualName() != null && context.getContextualName().equals(contextualName)).findFirst().orElseThrow(() -> new AssertionError("Could not find context with contextual name " + contextualName));
274+
private Observation.@NotNull Context getContextWithContextualNameEqualTo(List<Observation.Context> contexts,
275+
String contextualName) {
276+
return contexts.stream()
277+
.filter(context -> context.getContextualName() != null
278+
&& context.getContextualName().equals(contextualName))
279+
.findFirst()
280+
.orElseThrow(() -> new AssertionError("Could not find context with contextual name " + contextualName));
277281
}
278282

279283
@Test
@@ -282,27 +286,25 @@ void observesError() throws Exception {
282286
sqsTemplate.send(to -> to.queue(OBSERVES_ERROR_QUEUE_NAME).payload(messageBody));
283287
logger.debug("Sent message to queue {} with messageBody {}", OBSERVES_ERROR_QUEUE_NAME, messageBody);
284288
assertThat(latchContainer.observesErrorLatch.await(10, TimeUnit.SECONDS)).isTrue();
285-
await()
286-
.atMost(10, TimeUnit.SECONDS)
287-
.untilAsserted(() ->
288-
TestObservationRegistryAssert.then(observationRegistry)
289-
.hasHandledContextsThatSatisfy(contexts -> {
290-
ObservationContextAssert.then(getContextWithContextualNameEqualTo(contexts, "observes_error_test_queue send")).hasNameEqualTo("spring.aws.sqs.template")
291-
.isInstanceOf(AbstractTemplateObservation.Context.class)
292-
.doesNotHaveParentObservation();
293-
List<Observation.Context> receivingContexts = contexts.stream()
294-
.filter(context -> context.getContextualName() != null && context.getContextualName().equals("observes_error_test_queue receive"))
289+
await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> TestObservationRegistryAssert.then(observationRegistry)
290+
.hasHandledContextsThatSatisfy(contexts -> {
291+
ObservationContextAssert
292+
.then(getContextWithContextualNameEqualTo(contexts, "observes_error_test_queue send"))
293+
.hasNameEqualTo("spring.aws.sqs.template")
294+
.isInstanceOf(AbstractTemplateObservation.Context.class).doesNotHaveParentObservation();
295+
List<Observation.Context> receivingContexts = contexts.stream()
296+
.filter(context -> context.getContextualName() != null
297+
&& context.getContextualName().equals("observes_error_test_queue receive"))
295298
.toList();
296-
ObservationContextAssert.then(receivingContexts.get(0)).hasNameEqualTo("spring.aws.sqs.listener")
297-
.isInstanceOf(AbstractListenerObservation.Context.class)
298-
.doesNotHaveParentObservation().assertThatError().isInstanceOf(RuntimeException.class)
299+
ObservationContextAssert.then(receivingContexts.get(0)).hasNameEqualTo("spring.aws.sqs.listener")
300+
.isInstanceOf(AbstractListenerObservation.Context.class).doesNotHaveParentObservation()
301+
.assertThatError().isInstanceOf(RuntimeException.class)
299302
.hasMessage("Expected exception from observes-error");
300-
ObservationContextAssert.then(receivingContexts.get(1)).hasNameEqualTo("spring.aws.sqs.listener")
303+
ObservationContextAssert.then(receivingContexts.get(1)).hasNameEqualTo("spring.aws.sqs.listener")
301304
.isInstanceOf(AbstractListenerObservation.Context.class)
302305
.hasContextualNameEqualTo("observes_error_test_queue receive")
303306
.doesNotHaveParentObservation().doesNotHaveError();
304-
})
305-
);
307+
}));
306308
}
307309

308310
@Test

0 commit comments

Comments
 (0)