Skip to content

Commit bb20531

Browse files
authored
Merge pull request #1625 from yonghanlin/fix/nondeterminism_tests
Fix: fix four non-deterministic tests
2 parents 6c2f70b + 0cbc32f commit bb20531

3 files changed

Lines changed: 64 additions & 13 deletions

File tree

criteria/geode/test/org/immutables/criteria/geode/BindVariableConverterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void set() {
7474
check(s1).isA(HashSet.class);
7575

7676
Set<String> s2 = (Set<String>) converter.apply(ImmutableSet.of("a", "b"));
77-
check(s2).isOf("a", "b");
77+
check(s2).hasContentInAnyOrder("a", "b");
7878
check(s2).isA(HashSet.class);
7979
}
8080

criteria/mongo/test/org/immutables/criteria/mongo/bson4jackson/JacksonCodecsTest.java

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,60 @@ private static <T> T writeThenRead(CodecRegistry registry, ObjectMapper mapper,
170170
@JsonSerialize(as = ImmutableBsonModel.class)
171171
@JsonDeserialize(as = ImmutableBsonModel.class)
172172
interface BsonModel {
173-
java.util.Date utilDate();
174-
LocalDate localDate();
175-
Pattern pattern();
176-
ObjectId objectId();
177-
UUID uuid();
178-
Set<String> stringSet();
179-
Map<String, String> map();
180-
int[] intArray();
181-
List<Integer> intList();
182-
Document document();
183-
BsonDocument bsonDocument();
173+
@Value.Default
174+
default java.util.Date utilDate() {
175+
return DEFAULT.utilDate();
176+
}
177+
178+
@Value.Default
179+
default LocalDate localDate() {
180+
return DEFAULT.localDate();
181+
}
182+
183+
@Value.Default
184+
default Pattern pattern() {
185+
return DEFAULT.pattern();
186+
}
187+
188+
@Value.Default
189+
default ObjectId objectId() {
190+
return DEFAULT.objectId();
191+
}
192+
193+
@Value.Default
194+
default UUID uuid() {
195+
return DEFAULT.uuid();
196+
}
197+
198+
@Value.Default
199+
default Set<String> stringSet() {
200+
return DEFAULT.stringSet();
201+
}
202+
203+
@Value.Default
204+
default Map<String, String> map() {
205+
return DEFAULT.map();
206+
}
207+
208+
@Value.Default
209+
default int[] intArray() {
210+
return DEFAULT.intArray();
211+
}
212+
213+
@Value.Default
214+
default List<Integer> intList() {
215+
return DEFAULT.intList();
216+
}
217+
218+
@Value.Default
219+
default Document document() {
220+
return DEFAULT.document();
221+
}
222+
223+
@Value.Default
224+
default BsonDocument bsonDocument() {
225+
return DEFAULT.bsonDocument();
226+
}
184227
}
185228

186229
}

value-fixture/test/org/immutables/fixture/jackson/ObjectMappedTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,18 @@ public void jsonValueSingletonRoundtrip() throws Exception {
249249
@Test
250250
public void jsonStagedEntityRoundtrip() throws Exception {
251251
String json = "{\"required\":\"id\",\"optional\":null,\"optionalPrimitive\":null}";
252+
String jsonRegex = "\\{(?:"
253+
+ "\"required\":\"id\",\"optional\":\"default\",\"optionalPrimitive\":false"
254+
+ "|\"required\":\"id\",\"optionalPrimitive\":false,\"optional\":\"default\""
255+
+ "|\"optional\":\"default\",\"required\":\"id\",\"optionalPrimitive\":false"
256+
+ "|\"optional\":\"default\",\"optionalPrimitive\":false,\"required\":\"id\""
257+
+ "|\"optionalPrimitive\":false,\"required\":\"id\",\"optional\":\"default\""
258+
+ "|\"optionalPrimitive\":false,\"optional\":\"default\",\"required\":\"id\""
259+
+ ")\\}";
252260

253261
StagedEntity nullable =
254262
OBJECT_MAPPER.readValue(json, StagedEntity.class);
255263

256-
check(OBJECT_MAPPER.writeValueAsString(nullable)).is("{\"required\":\"id\",\"optional\":\"default\",\"optionalPrimitive\":false}");
264+
check(OBJECT_MAPPER.writeValueAsString(nullable)).matches(jsonRegex);
257265
}
258266
}

0 commit comments

Comments
 (0)