|
18 | 18 | import java.util.zip.ZipInputStream; |
19 | 19 | import java.net.*; |
20 | 20 |
|
| 21 | +import com.cloudinary.*; |
| 22 | +import org.cloudinary.json.JSONArray; |
21 | 23 | import org.junit.Before; |
22 | 24 | import org.junit.BeforeClass; |
23 | 25 | import org.junit.AfterClass; |
24 | 26 | import org.junit.Rule; |
25 | 27 | import org.junit.Test; |
26 | 28 | import org.junit.rules.TestName; |
27 | 29 |
|
28 | | -import com.cloudinary.ArchiveParams; |
29 | | -import com.cloudinary.Cloudinary; |
30 | | -import com.cloudinary.Coordinates; |
31 | | -import com.cloudinary.ResponsiveBreakpoints; |
32 | | -import com.cloudinary.Transformation; |
| 30 | +import com.cloudinary.ResponsiveBreakpoint; |
33 | 31 | import com.cloudinary.utils.ObjectUtils; |
34 | 32 | import com.cloudinary.utils.Rectangle; |
35 | 33 |
|
@@ -438,12 +436,32 @@ public void testFilenameOption() throws Exception { |
438 | 436 |
|
439 | 437 | @Test |
440 | 438 | public void testResponsiveBreakpoints() throws Exception { |
441 | | - Map result = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("responsive_breakpoints", |
442 | | - new ResponsiveBreakpoints().maxImages(2).createDerived(false) |
| 439 | + ResponsiveBreakpoint breakpoint = new ResponsiveBreakpoint().maxImages(2).createDerived(false); |
| 440 | + |
| 441 | + // A single breakpoint |
| 442 | + Map result = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("responsive_breakpoints", |
| 443 | + breakpoint |
443 | 444 | )); |
444 | 445 | java.util.ArrayList breakpointsResponse = (java.util.ArrayList) result.get("responsive_breakpoints"); |
445 | 446 | java.util.ArrayList breakpoints = (java.util.ArrayList)((Map) breakpointsResponse.get(0)).get("breakpoints"); |
446 | 447 | assertEquals(2, breakpoints.size()); |
| 448 | + |
| 449 | + // an array of breakpoints |
| 450 | + result = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("responsive_breakpoints", |
| 451 | + new ResponsiveBreakpoint [] {breakpoint} |
| 452 | + )); |
| 453 | + breakpointsResponse = (java.util.ArrayList) result.get("responsive_breakpoints"); |
| 454 | + breakpoints = (java.util.ArrayList)((Map) breakpointsResponse.get(0)).get("breakpoints"); |
| 455 | + assertEquals(2, breakpoints.size()); |
| 456 | + |
| 457 | + // a JSONArray of breakpoints |
| 458 | + JSONArray array = new JSONArray(); |
| 459 | + array.put(breakpoint); |
| 460 | + result = cloudinary.uploader().upload(SRC_TEST_IMAGE, ObjectUtils.asMap("responsive_breakpoints", array |
| 461 | + )); |
| 462 | + breakpointsResponse = (java.util.ArrayList) result.get("responsive_breakpoints"); |
| 463 | + breakpoints = (java.util.ArrayList)((Map) breakpointsResponse.get(0)).get("breakpoints"); |
| 464 | + assertEquals(2, breakpoints.size()); |
447 | 465 | } |
448 | 466 |
|
449 | 467 | @Test |
|
0 commit comments