Skip to content

Commit 4e20b75

Browse files
committed
web: fix tests for consumer-aware getExplorePageData + peek signatures
The earlier consumer-aware peek work changed two SPI surfaces that the web tests still called with the old shape, so CI failed at compile time on rqueue-web:compileTestJava. RqueueQDetailService.getExplorePageData gained a String consumerName between DataType and pageNumber. Updated five call sites in RqueueQDetailServiceTest and three in RqueueQDetailServiceBrokerRoutingTest to pass null for consumerName. MessageBroker.peek gained a consumer-aware 4-arg overload, and the production explorer path now calls that overload. Two stubbings and one verify in RqueueQDetailServiceBrokerRoutingTest were still matching peek(QueueDetail, long, long) — strict Mockito reported a PotentialStubbingProblem. Updated to nullable(String.class) for the consumer arg so the stub matches both the explicit-null and any future non-null call sites. Assisted-By: Claude Code
1 parent 4c777f1 commit 4e20b75

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

rqueue-web/src/test/java/com/github/sonus21/rqueue/web/service/RqueueQDetailServiceBrokerRoutingTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static org.junit.jupiter.api.Assertions.assertTrue;
2323
import static org.mockito.ArgumentMatchers.any;
2424
import static org.mockito.ArgumentMatchers.anyLong;
25+
import static org.mockito.ArgumentMatchers.nullable;
2526
import static org.mockito.Mockito.atLeastOnce;
2627
import static org.mockito.Mockito.never;
2728
import static org.mockito.Mockito.verify;
@@ -175,7 +176,7 @@ void scheduledAndRunningTabsHiddenForNatsBroker() {
175176

176177
when(rqueueSystemManagerService.getQueueConfig(queueConfig.getName())).thenReturn(queueConfig);
177178
DataViewResponse explore = service.getExplorePageData(
178-
queueConfig.getName(), queueConfig.getScheduledQueueName(), DataType.ZSET, 0, 10);
179+
queueConfig.getName(), queueConfig.getScheduledQueueName(), DataType.ZSET, null, 0, 10);
179180
assertTrue(explore.isHideScheduledPanel());
180181
assertTrue(explore.isHideCronJobs());
181182
assertTrue(explore.getRows() == null || explore.getRows().isEmpty());
@@ -185,27 +186,27 @@ void scheduledAndRunningTabsHiddenForNatsBroker() {
185186
void peekRoutesThroughBrokerForReadyList() {
186187
service.setMessageBroker(messageBroker);
187188
when(messageBroker.capabilities()).thenReturn(Capabilities.REDIS_DEFAULTS);
188-
when(messageBroker.peek(any(QueueDetail.class), anyLong(), anyLong()))
189+
when(messageBroker.peek(any(QueueDetail.class), nullable(String.class), anyLong(), anyLong()))
189190
.thenReturn(Collections.emptyList());
190191
when(rqueueSystemManagerService.getQueueConfig(queueConfig.getName())).thenReturn(queueConfig);
191192

192193
DataViewResponse response = service.getExplorePageData(
193-
queueConfig.getName(), queueConfig.getQueueName(), DataType.LIST, 0, 10);
194+
queueConfig.getName(), queueConfig.getQueueName(), DataType.LIST, null, 0, 10);
194195

195-
verify(messageBroker, atLeastOnce()).peek(any(QueueDetail.class), anyLong(), anyLong());
196+
verify(messageBroker, atLeastOnce()).peek(any(QueueDetail.class), nullable(String.class), anyLong(), anyLong());
196197
assertTrue(response.getRows() == null || response.getRows().isEmpty());
197198
}
198199

199200
@Test
200201
void hideFlagsDefaultFalseWithRedisBroker() {
201202
service.setMessageBroker(messageBroker);
202203
when(messageBroker.capabilities()).thenReturn(Capabilities.REDIS_DEFAULTS);
203-
when(messageBroker.peek(any(QueueDetail.class), anyLong(), anyLong()))
204+
when(messageBroker.peek(any(QueueDetail.class), nullable(String.class), anyLong(), anyLong()))
204205
.thenReturn(Collections.emptyList());
205206
when(rqueueSystemManagerService.getQueueConfig(queueConfig.getName())).thenReturn(queueConfig);
206207

207208
DataViewResponse response = service.getExplorePageData(
208-
queueConfig.getName(), queueConfig.getQueueName(), DataType.LIST, 0, 10);
209+
queueConfig.getName(), queueConfig.getQueueName(), DataType.LIST, null, 0, 10);
209210

210211
assertFalse(response.isHideScheduledPanel());
211212
assertFalse(response.isHideCronJobs());

rqueue-web/src/test/java/com/github/sonus21/rqueue/web/service/RqueueQDetailServiceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void getExplorePageDataQueue() {
239239
doReturn(queueConfig).when(rqueueSystemManagerService).getQueueConfig("test");
240240
doReturn(rqueueMessages).when(rqueueMessageTemplate).readFromList("test", 0, 9);
241241
DataViewResponse response =
242-
rqueueQDetailService.getExplorePageData("test", "test", DataType.LIST, 0, 10);
242+
rqueueQDetailService.getExplorePageData("test", "test", DataType.LIST, null, 0, 10);
243243
assertEquals(expectedResponse, response);
244244
}
245245

@@ -273,7 +273,7 @@ void getExplorePageDataDeadLetterQueue() {
273273
doReturn(queueConfig).when(rqueueSystemManagerService).getQueueConfig("test");
274274
doReturn(rqueueMessages).when(rqueueMessageTemplate).readFromList("test-dlq", 0, 9);
275275
DataViewResponse response =
276-
rqueueQDetailService.getExplorePageData("test", "test-dlq", DataType.LIST, 0, 10);
276+
rqueueQDetailService.getExplorePageData("test", "test-dlq", DataType.LIST, null, 0, 10);
277277
for (TableRow row : response.getRows()) {
278278
assertNotEquals("", row.getColumns().get(3).getValue());
279279
row.getColumns().remove(3);
@@ -326,7 +326,7 @@ void getExplorePageDataTypeQueueDeleteFewItems() {
326326
doReturn(messageMetadata).when(rqueueMessageMetadataService).findAll(anyCollection());
327327
doReturn(queueConfig).when(rqueueSystemManagerService).getQueueConfig("test");
328328
DataViewResponse response =
329-
rqueueQDetailService.getExplorePageData("test", "test", DataType.LIST, 0, 10);
329+
rqueueQDetailService.getExplorePageData("test", "test", DataType.LIST, null, 0, 10);
330330
assertEquals(expectedResponse, response);
331331
}
332332

@@ -364,7 +364,7 @@ void getExplorePageDataTypeScheduledQueue() {
364364
doReturn(queueConfig).when(rqueueSystemManagerService).getQueueConfig("test");
365365
doReturn(rqueueMessages).when(rqueueMessageTemplate).readFromZset("__rq::d-queue::test", 0, 9);
366366
DataViewResponse response = rqueueQDetailService.getExplorePageData(
367-
"test", "__rq::d-queue::test", DataType.ZSET, 0, 10);
367+
"test", "__rq::d-queue::test", DataType.ZSET, null, 0, 10);
368368
// clear time left
369369
for (TableRow tableRow : response.getRows()) {
370370
tableRow.getColumns().remove(3);
@@ -409,7 +409,7 @@ void getExplorePageDataTypeProcessingQueue() {
409409
.readFromZsetWithScore("__rq::p-queue::test", 0, 9);
410410

411411
DataViewResponse response = rqueueQDetailService.getExplorePageData(
412-
"test", "__rq::p-queue::test", DataType.ZSET, 0, 10);
412+
"test", "__rq::p-queue::test", DataType.ZSET, null, 0, 10);
413413
// clear time left
414414
for (TableRow tableRow : response.getRows()) {
415415
tableRow.getColumns().remove(3);

0 commit comments

Comments
 (0)