Skip to content

Commit

Permalink
Merge pull request springwolf#681 from ctasada/ctasada/fix-message-re…
Browse files Browse the repository at this point in the history
…f-order

fix: Sort Messages references
  • Loading branch information
ctasada authored Apr 4, 2024
2 parents 514943d + c30a87e commit 006680b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.springwolf.asyncapi.v3.model.operation.Operation;

import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -62,6 +63,9 @@ private static List<MessageReference> mergeMessageReferences(
if (otherMessages != null) {
messageReferences.addAll(otherMessages);
}
return messageReferences.stream().toList();

return messageReferences.stream()
.sorted(Comparator.comparing(MessageReference::getRef))
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void shouldMergeDifferentMessageForSameOperation() {
// then expectedMessage only includes message1 and message2.
// Message3 is not included as it is identical in terms of payload type (Message#name) to message 2
assertThat(mergedOperations).hasSize(1).hasEntrySatisfying(operationId, it -> {
assertThat(it.getMessages()).containsExactlyInAnyOrder(messageRef1, messageRef2);
assertThat(it.getMessages()).containsExactly(messageRef2, messageRef1);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@
},
"messages": [
{
"$ref": "#/channels/multi-payload-queue/messages/io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto"
"$ref": "#/channels/multi-payload-queue/messages/io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto"
},
{
"$ref": "#/channels/multi-payload-queue/messages/io.github.springwolf.examples.amqp.dtos.AnotherPayloadDto"
"$ref": "#/channels/multi-payload-queue/messages/io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto"
}
]
}
Expand Down

0 comments on commit 006680b

Please sign in to comment.