1313import redis .clients .jedis .search .Document ;
1414
1515import static org .junit .jupiter .api .Assertions .assertEquals ;
16+ import static org .junit .jupiter .api .Assertions .assertTrue ;
1617
1718public class DocumentTest {
1819
@@ -38,13 +39,8 @@ public void serialize() throws IOException, ClassNotFoundException {
3839
3940 assertEquals (id , read .getId ());
4041 assertEquals (score , read .getScore (), 0d );
41-
42- // use english language to make sure the decimal separator is the same as the toString
43- String exp = String .format (Locale .ENGLISH , "id:%s, score: %.1f, properties:%s" ,
44- id , score , "[string=c, float=12.0]" );
45- assertEquals (exp , read .toString ());
4642 assertEquals ("c" , read .getString ("string" ));
47- assertEquals (Double . valueOf ( 12d ) , read .get ("float" ));
43+ assertEquals (12d , read .get ("float" ));
4844 }
4945
5046 @ Test
@@ -57,8 +53,14 @@ public void toStringTest() {
5753 Document document = new Document (id , map , score );
5854
5955 // use english language to make sure the decimal separator is the same as the toString
60- String expected = String .format (Locale .ENGLISH , "id:%s, score: %.1f, properties:%s" ,
61- id , score , "[string=c, float=12.0]" );
62- assertEquals (expected , document .toString ());
56+ String expected1 = String .format (Locale .ENGLISH , "id:%s, score: %.1f, properties:%s" , id , score ,
57+ "[string=c, float=12.0]" );
58+ String expected2 = String .format (Locale .ENGLISH , "id:%s, score: %.1f, properties:%s" , id , score ,
59+ "[float=12.0, string=c]" );
60+
61+ // the order of the properties is not guaranteed, so we check both possible outcomes
62+ String actual = document .toString ();
63+ assertTrue (actual .equals (expected1 ) || actual .equals (expected2 ));
6364 }
65+
6466}
0 commit comments