From d6dea414bbb8a5eed19047317dc8a1a7c6d414a5 Mon Sep 17 00:00:00 2001 From: Nikita Shupletsov Date: Wed, 7 Aug 2024 13:33:07 -0700 Subject: [PATCH] [AMQ-8354] Fix sequence storage tests. --- .../storage/ReplicaSequenceStorageTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/activemq-broker/src/test/java/org/apache/activemq/replica/storage/ReplicaSequenceStorageTest.java b/activemq-broker/src/test/java/org/apache/activemq/replica/storage/ReplicaSequenceStorageTest.java index 2832b7f5ef6..0229c15a02e 100644 --- a/activemq-broker/src/test/java/org/apache/activemq/replica/storage/ReplicaSequenceStorageTest.java +++ b/activemq-broker/src/test/java/org/apache/activemq/replica/storage/ReplicaSequenceStorageTest.java @@ -103,8 +103,16 @@ public void shouldInitializeWhenMoreThanOneExist() throws Exception { .thenReturn(List.of(new IndirectMessageReference(message1), new IndirectMessageReference(message2))); String initialize = replicaSequenceStorage.initialize(connectionContext); - assertThat(initialize).isEqualTo(message1.getText()); - verify(sequenceQueue, times(1)).removeMessage(eq(message1.getMessageId().toString())); + assertThat(initialize).isEqualTo(message2.getText()); + + ArgumentCaptor ackArgumentCaptor = ArgumentCaptor.forClass(MessageAck.class); + verify(broker).acknowledge(any(), ackArgumentCaptor.capture()); + MessageAck value = ackArgumentCaptor.getValue(); + assertThat(value.getFirstMessageId()).isEqualTo(message1.getMessageId()); + assertThat(value.getLastMessageId()).isEqualTo(message1.getMessageId()); + assertThat(value.getDestination()).isEqualTo(sequenceQueueDestination); + assertThat(value.getMessageCount()).isEqualTo(1); + assertThat(value.getAckType()).isEqualTo(MessageAck.STANDARD_ACK_TYPE); } @Test @@ -145,7 +153,7 @@ public void shouldAcknowledgeAllMessagesWhenEnqueue() throws Exception { when(messageReference2.getMessage()).thenReturn(message2); when(messageReference2.getMessageId()).thenReturn(message2.getMessageId()); - when(subscription.getDispatched()).thenReturn(List.of(messageReference1, messageReference2)); + when(subscription.getDispatched()).thenReturn(List.of(), List.of(messageReference1, messageReference2)); replicaSequenceStorage.initialize(connectionContext); ArgumentCaptor ackArgumentCaptor = ArgumentCaptor.forClass(MessageAck.class);