|
3 | 3 | import java.io.UnsupportedEncodingException; |
4 | 4 | import java.net.URI; |
5 | 5 | import java.net.URLDecoder; |
6 | | -import java.util.Arrays; |
7 | | -import java.util.HashMap; |
8 | | -import java.util.Map; |
| 6 | +import java.util.*; |
9 | 7 | import java.util.regex.Matcher; |
10 | 8 | import java.util.regex.Pattern; |
11 | 9 |
|
@@ -977,28 +975,20 @@ public void testOverlayError2() { |
977 | 975 | @Test |
978 | 976 | public void testResponsiveBreakpointsToJson() { |
979 | 977 | assertEquals("an empty ResponsiveBreakpoint should have create_derived=true", |
980 | | - "[{\"create_derived\":true}]", |
| 978 | + "{\"create_derived\":true}", |
981 | 979 | new ResponsiveBreakpoint().toString() |
982 | 980 | ); |
983 | | - JSONObject expected = new JSONObject("{\"create_derived\":false,\"max_width\":500,\"min_width\":100,\"max_images\":5,\"transformation\":\"a_45\"}"); |
| 981 | + String[] expectedArr = "{\"create_derived\":false,\"max_width\":500,\"min_width\":100,\"max_images\":5,\"transformation\":\"a_45\"}".split("[{}]")[1].split(",(?=\")"); |
| 982 | + Arrays.sort(expectedArr); |
984 | 983 | JSONObject actual = new ResponsiveBreakpoint().createDerived(false) |
985 | 984 | .transformation(new Transformation().angle(45)) |
986 | 985 | .maxWidth(500) |
987 | 986 | .minWidth(100) |
988 | 987 | .maxImages(5) |
989 | 988 | ; |
990 | | - assertTrue(actual.similar(expected)); |
991 | | - |
992 | | - JSONArray actualArray = new JSONArray(Arrays.asList( |
993 | | - new ResponsiveBreakpoint().createDerived(false) |
994 | | - .transformation(new Transformation().angle(45)) |
995 | | - .maxWidth(500) |
996 | | - .minWidth(100) |
997 | | - .maxImages(5), |
998 | | - new ResponsiveBreakpoint() |
999 | | - ));; |
1000 | | - JSONArray expectedArray = new JSONArray("[{\"create_derived\":false,\"max_width\":500,\"min_width\":100,\"max_images\":5,\"transformation\":\"a_45\"},{\"create_derived\":true}]"); |
1001 | | - assertTrue(actualArray.similar(expectedArray)); |
| 989 | + String[] actualArr = actual.toString().split("[{}]")[1].split(",(?=\")"); |
| 990 | + Arrays.sort(actualArr); |
| 991 | + assertArrayEquals(expectedArr, actualArr); |
1002 | 992 | } |
1003 | 993 |
|
1004 | 994 | public static Map<String, String> getUrlParameters(URI uri) throws UnsupportedEncodingException { |
|
0 commit comments