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 c626858a1a..5271dc1551 100644 --- a/src/test/java/redis/clients/jedis/modules/search/DocumentTest.java +++ b/src/test/java/redis/clients/jedis/modules/search/DocumentTest.java @@ -13,6 +13,7 @@ import redis.clients.jedis.search.Document; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DocumentTest { @@ -38,13 +39,8 @@ public void serialize() throws IOException, ClassNotFoundException { assertEquals(id, read.getId()); 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", - id, score, "[string=c, float=12.0]"); - assertEquals(exp, read.toString()); assertEquals("c", read.getString("string")); - assertEquals(Double.valueOf(12d), read.get("float")); + assertEquals(12d, read.get("float")); } @Test @@ -57,8 +53,14 @@ 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", - id, score, "[string=c, float=12.0]"); - assertEquals(expected, document.toString()); + String expected1 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", id, score, + "[string=c, float=12.0]"); + String expected2 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s", id, score, + "[float=12.0, string=c]"); + + // the order of the properties is not guaranteed, so we check both possible outcomes + String actual = document.toString(); + assertTrue(actual.equals(expected1) || actual.equals(expected2)); } + }