|
4 | 4 | import com.cloudinary.transformation.TextLayer; |
5 | 5 | import com.cloudinary.utils.ObjectUtils; |
6 | 6 | import org.cloudinary.json.JSONArray; |
| 7 | +import org.hamcrest.CoreMatchers; |
7 | 8 | import org.junit.After; |
8 | 9 | import org.junit.Before; |
9 | 10 | import org.junit.Test; |
| 11 | +import org.junit.runner.RunWith; |
| 12 | + |
| 13 | +import junitparams.JUnitParamsRunner; |
| 14 | +import junitparams.Parameters; |
10 | 15 |
|
11 | 16 | import java.util.*; |
12 | 17 |
|
|
18 | 23 | * |
19 | 24 | */ |
20 | 25 | @SuppressWarnings("unchecked") |
| 26 | +@RunWith(JUnitParamsRunner.class) |
21 | 27 | public class TransformationTest { |
22 | 28 |
|
23 | 29 | @Before |
@@ -300,4 +306,67 @@ public void testContextMetadataToUserVariables() { |
300 | 306 |
|
301 | 307 | assertEquals("$xpos_ctx:!x_pos!_to_f,$ypos_ctx:!y_pos!_to_f,c_crop,x_$xpos_mul_w,y_$ypos_mul_h", t.generate()); |
302 | 308 | } |
| 309 | + |
| 310 | + @Parameters({ "angle", |
| 311 | + "aspect_ratio", |
| 312 | + "dpr", |
| 313 | + "effect", |
| 314 | + "height", |
| 315 | + "opacity", |
| 316 | + "quality", |
| 317 | + "width", |
| 318 | + "x", |
| 319 | + "y", |
| 320 | + "end_offset", |
| 321 | + "start_offset", |
| 322 | + "zoom" }) |
| 323 | + @Test |
| 324 | + public void testVerifyNormalizationShouldNormalize(String input) throws Exception { |
| 325 | + String t = new Transformation().param(input, "width * 2").generate(); |
| 326 | + assertThat(t, CoreMatchers.containsString("w_mul_2")); |
| 327 | + } |
| 328 | + |
| 329 | + @Parameters({ |
| 330 | + "audio_codec", |
| 331 | + "audio_frequency", |
| 332 | + "border", |
| 333 | + "bit_rate", |
| 334 | + "color_space", |
| 335 | + "default_image", |
| 336 | + "delay", |
| 337 | + "density", |
| 338 | + "fetch_format", |
| 339 | + "custom_function", |
| 340 | + "fps", |
| 341 | + "gravity", |
| 342 | + "overlay", |
| 343 | + "prefix", |
| 344 | + "page", |
| 345 | + "underlay", |
| 346 | + "video_sampling", |
| 347 | + "streaming_profile", |
| 348 | + "keyframe_interval"}) |
| 349 | + @Test |
| 350 | + public void test1VerifyNormalizationShouldNotNormalize(String input) throws Exception { |
| 351 | + String t = new Transformation().param(input, "width * 2").generate(); |
| 352 | + assertThat(t, CoreMatchers.not(CoreMatchers.containsString("w_mul_2"))); |
| 353 | + } |
| 354 | + |
| 355 | + @Test |
| 356 | + public void testSupportStartOffset() throws Exception { |
| 357 | + String t = new Transformation().width(100).startOffset("idu - 5").generate(); |
| 358 | + assertThat(t, CoreMatchers.containsString("so_idu_sub_5")); |
| 359 | + |
| 360 | + t = new Transformation().width(100).startOffset("$logotime").generate(); |
| 361 | + assertThat(t, CoreMatchers.containsString("so_$logotime")); |
| 362 | + } |
| 363 | + |
| 364 | + @Test |
| 365 | + public void testSupportEndOffset() throws Exception { |
| 366 | + String t = new Transformation().width(100).endOffset("idu - 5").generate(); |
| 367 | + assertThat(t, CoreMatchers.containsString("eo_idu_sub_5")); |
| 368 | + |
| 369 | + t = new Transformation().width(100).endOffset("$logotime").generate(); |
| 370 | + assertThat(t, CoreMatchers.containsString("eo_$logotime")); |
| 371 | + } |
303 | 372 | } |
0 commit comments