From 2f3c352000a3c7afa03f62ade01fc88dd5eb961a Mon Sep 17 00:00:00 2001 From: sandhu5 Date: Thu, 16 Nov 2023 10:43:58 -0600 Subject: [PATCH] Fix flaky tests in DocumentTest --- .../jedis/modules/search/DocumentTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/test/java/redis/clients/jedis/modules/search/DocumentTest.java b/src/test/java/redis/clients/jedis/modules/search/DocumentTest.java index 490837ebd4..1ba0b38744 100644 --- a/src/test/java/redis/clients/jedis/modules/search/DocumentTest.java +++ b/src/test/java/redis/clients/jedis/modules/search/DocumentTest.java @@ -1,6 +1,7 @@ package redis.clients.jedis.modules.search; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -40,9 +41,12 @@ public void serialize() throws IOException, ClassNotFoundException { assertEquals(score, read.getScore(), 0d); // use english language to make sure the decimal separator is the same as the toString - String exp = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", + String exp1 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", id, score, "[string=c, float=12.0]"); - assertEquals(exp, read.toString()); + String exp2 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", + id, score, "[float=12.0, string=c]"); + String actual = read.toString(); + assertTrue(actual.equals(exp1)||actual.equals(exp2)); assertEquals("c", read.getString("string")); assertEquals(Double.valueOf(12d), read.get("float")); } @@ -57,8 +61,11 @@ public void toStringTest() { Document document = new Document(id, map, score); // use english language to make sure the decimal separator is the same as the toString - String expected = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", + String expected1 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", id, score, "[string=c, float=12.0]"); - assertEquals(expected, document.toString()); + String expected2 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", + id, score, "[float=12.0, string=c]"); + String actual = document.toString(); + assertTrue(actual.equals(expected1)||actual.equals(expected2)); } }