From 10ceba8c0a1b2f9575b47798c19e957f237fdeb8 Mon Sep 17 00:00:00 2001 From: Maurice van Veen Date: Mon, 4 Mar 2024 21:45:40 +0100 Subject: [PATCH] Test create paused consumer Signed-off-by: Maurice van Veen --- .../client/impl/JetStreamManagementTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/io/nats/client/impl/JetStreamManagementTests.java b/src/test/java/io/nats/client/impl/JetStreamManagementTests.java index e32ca61ee..39f55c056 100644 --- a/src/test/java/io/nats/client/impl/JetStreamManagementTests.java +++ b/src/test/java/io/nats/client/impl/JetStreamManagementTests.java @@ -753,6 +753,28 @@ public void testAddDeleteConsumer() throws Exception { }); } + @Test + public void testAddPausedConsumer() throws Exception { + runInJsServer(nc -> { + JetStreamManagement jsm = nc.jetStreamManagement(); + + createMemoryStream(jsm, STREAM, subjectDot(">")); + + List list = jsm.getConsumers(STREAM); + assertEquals(0, list.size()); + + ZonedDateTime pauseUntil = ZonedDateTime.now(ZONE_ID_GMT).plusSeconds(30); + ConsumerConfiguration cc = ConsumerConfiguration.builder() + .pauseUntil(pauseUntil) + .build(); + + // Consumer should be paused on creation. + ConsumerInfo ci = jsm.addOrUpdateConsumer(STREAM, cc); + assertTrue(ci.getPaused()); + assertEquals(pauseUntil, ci.getConsumerConfiguration().getPauseUntil()); + }); + } + @Test public void testPauseResumeConsumer() throws Exception { runInJsServer(nc -> {