13
13
import redis .clients .jedis .search .Document ;
14
14
15
15
import static org .junit .jupiter .api .Assertions .assertEquals ;
16
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
16
17
17
18
public class DocumentTest {
18
19
@@ -38,13 +39,8 @@ public void serialize() throws IOException, ClassNotFoundException {
38
39
39
40
assertEquals (id , read .getId ());
40
41
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 ());
46
42
assertEquals ("c" , read .getString ("string" ));
47
- assertEquals (Double . valueOf ( 12d ) , read .get ("float" ));
43
+ assertEquals (12d , read .get ("float" ));
48
44
}
49
45
50
46
@ Test
@@ -57,8 +53,14 @@ public void toStringTest() {
57
53
Document document = new Document (id , map , score );
58
54
59
55
// 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 ));
63
64
}
65
+
64
66
}
0 commit comments