diff --git a/gson/src/test/java/com/google/gson/functional/EnumTest.java b/gson/src/test/java/com/google/gson/functional/EnumTest.java index 5103a045c0..fde60a4afe 100644 --- a/gson/src/test/java/com/google/gson/functional/EnumTest.java +++ b/gson/src/test/java/com/google/gson/functional/EnumTest.java @@ -38,6 +38,7 @@ import java.util.EnumSet; import java.util.Map; import java.util.Set; +import java.util.HashSet; import org.junit.Before; import org.junit.Test; @@ -93,7 +94,7 @@ public void testCollectionOfEnumsDeserialization() { @Test public void testClassWithEnumFieldSerialization() { ClassWithEnumFields target = new ClassWithEnumFields(); - assertThat(gson.toJson(target)).isEqualTo(target.getExpectedJson()); + assertThat(target.getExpectedJson().contains(gson.toJson(target))).isTrue();; } @Test @@ -111,9 +112,12 @@ private static enum MyEnum { private static class ClassWithEnumFields { private final MyEnum value1 = MyEnum.VALUE1; private final MyEnum value2 = MyEnum.VALUE2; - public String getExpectedJson() { - return "{\"value1\":\"" + value1 + "\",\"value2\":\"" + value2 + "\"}"; - } + public Set getExpectedJson() { + Set possiblejsonvalues = new HashSet(); + possiblejsonvalues.add("{\"value1\":\"" + value1 + "\",\"value2\":\"" + value2 + "\"}"); + possiblejsonvalues.add("{\"value2\":\"" + value2 + "\",\"value1\":\"" + value1 + "\"}"); + return possiblejsonvalues; + } } /**