From b2448510acf9fca243b78092af6838dd0fe86cd2 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 28 May 2026 15:17:52 -0400 Subject: [PATCH] client/java: add browseChildrenRejectsRepeatedPageToken test for parity --- .../client/GalaxyRepositoryClientTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/clients/java/zb-mom-ww-mxgateway-client/src/test/java/com/zb/mom/ww/mxgateway/client/GalaxyRepositoryClientTests.java b/clients/java/zb-mom-ww-mxgateway-client/src/test/java/com/zb/mom/ww/mxgateway/client/GalaxyRepositoryClientTests.java index ba84e34..88f6f58 100644 --- a/clients/java/zb-mom-ww-mxgateway-client/src/test/java/com/zb/mom/ww/mxgateway/client/GalaxyRepositoryClientTests.java +++ b/clients/java/zb-mom-ww-mxgateway-client/src/test/java/com/zb/mom/ww/mxgateway/client/GalaxyRepositoryClientTests.java @@ -203,6 +203,27 @@ final class GalaxyRepositoryClientTests { } } + @Test + void browseChildrenRejectsRepeatedPageToken() throws Exception { + // Queue the same BrowseChildrenReply twice with a non-empty NextPageToken. + // The client will request a second page and detect that the token repeats. + BrowseChildrenService service = new BrowseChildrenService(); + BrowseChildrenReply repeatedReply = browseReply( + List.of(obj(1, "Plant", true)), + List.of(true), + 1L, + "1:abc:1"); + service.replies.add(repeatedReply); + service.replies.add(repeatedReply); + + try (InProcessGalaxy g = InProcessGalaxy.start(service, new AtomicReference<>()); + GalaxyRepositoryClient client = g.client("")) { + MxGatewayException error = assertThrows(MxGatewayException.class, client::browse); + + assertTrue(error.getMessage().contains("repeated page token")); + } + } + @Test void watchDeployEventsReceivesEventsInOrder() throws Exception { DeployEvent first = DeployEvent.newBuilder()