77import com .cloudinary .api .ApiResponse ;
88import com .cloudinary .api .exceptions .BadRequest ;
99import com .cloudinary .api .exceptions .NotFound ;
10+ import com .cloudinary .transformation .TextLayer ;
1011import com .cloudinary .utils .ObjectUtils ;
1112import static org .hamcrest .Matchers .hasEntry ;
1213import static org .hamcrest .Matchers .hasItem ;
@@ -37,6 +38,9 @@ abstract public class AbstractApiTest extends MockableTest {
3738 public static final String API_TEST_UPLOAD_PRESET_3 = API_TEST_UPLOAD_PRESET + "3" ;
3839 public static final String API_TEST_UPLOAD_PRESET_4 = API_TEST_UPLOAD_PRESET + "4" ;
3940 public static final String [] UPLOAD_TAGS = {SDK_TEST_TAG , uniqueTag };
41+ public static final String EXPLICIT_TRANSFORMATION_NAME = "c_scale,l_text:Arial_60:" + SUFFIX + ",w_100" ;
42+ public static final Transformation EXPLICIT_TRANSFORMATION = new Transformation ().width (100 ).crop ("scale" ).overlay (new TextLayer ().text (SUFFIX ).fontFamily ("Arial" ).fontSize (60 ));
43+
4044 protected Api api ;
4145
4246 @ BeforeClass
@@ -47,7 +51,7 @@ public static void setUpClass() throws IOException {
4751 return ;
4852 }
4953 Map options = ObjectUtils .asMap ("public_id" , API_TEST , "tags" , new String []{SDK_TEST_TAG , uniqueTag }, "context" , "key=value" , "eager" ,
50- Collections .singletonList (new Transformation (). width ( 100 ). crop ( "scale" ) ));
54+ Collections .singletonList (EXPLICIT_TRANSFORMATION ));
5155 cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
5256 options .put ("public_id" , API_TEST_1 );
5357 cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
@@ -330,7 +334,7 @@ public void test11TagsPrefix() throws Exception {
330334 public void test12Transformations () throws Exception {
331335 // should allow listing transformations
332336 Map result = api .transformations (ObjectUtils .emptyMap ());
333- Map transformation = findByAttr ((List <Map >) result .get ("transformations" ), "name" , "c_scale,w_100" );
337+ Map transformation = findByAttr ((List <Map >) result .get ("transformations" ), "name" , EXPLICIT_TRANSFORMATION_NAME );
334338
335339 assertNotNull (transformation );
336340 assertTrue ((Boolean ) transformation .get ("used" ));
@@ -339,22 +343,21 @@ public void test12Transformations() throws Exception {
339343 @ Test
340344 public void test13TransformationMetadata () throws Exception {
341345 // should allow getting transformation metadata
342- final Transformation tr = new Transformation ().crop ("scale" ).width (100 );
343- preloadResource (ObjectUtils .asMap ("eager" , Collections .singletonList (tr )));
344- Map transformation = api .transformation ("c_scale,w_100" , ObjectUtils .asMap ("max_results" , 500 ));
346+ preloadResource (ObjectUtils .asMap ("eager" , Collections .singletonList (EXPLICIT_TRANSFORMATION )));
347+ Map transformation = api .transformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .asMap ("max_results" , 500 ));
345348 assertNotNull (transformation );
346- assertEquals (new Transformation ((List <Map >) transformation .get ("info" )).generate (), tr .generate ());
349+ assertEquals (new Transformation ((List <Map >) transformation .get ("info" )).generate (), EXPLICIT_TRANSFORMATION .generate ());
347350 }
348351
349352 @ Test
350353 public void test14TransformationUpdate () throws Exception {
351354 // should allow updating transformation allowed_for_strict
352- api .updateTransformation ("c_scale,w_100" , ObjectUtils .asMap ("allowed_for_strict" , true ), ObjectUtils .emptyMap ());
353- Map transformation = api .transformation ("c_scale,w_100" , ObjectUtils .emptyMap ());
355+ api .updateTransformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .asMap ("allowed_for_strict" , true ), ObjectUtils .emptyMap ());
356+ Map transformation = api .transformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .emptyMap ());
354357 assertNotNull (transformation );
355358 assertEquals (transformation .get ("allowed_for_strict" ), true );
356- api .updateTransformation ("c_scale,w_100" , ObjectUtils .asMap ("allowed_for_strict" , false ), ObjectUtils .emptyMap ());
357- transformation = api .transformation ("c_scale,w_100" , ObjectUtils .emptyMap ());
359+ api .updateTransformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .asMap ("allowed_for_strict" , false ), ObjectUtils .emptyMap ());
360+ transformation = api .transformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .emptyMap ());
358361 assertNotNull (transformation );
359362 assertEquals (transformation .get ("allowed_for_strict" ), false );
360363 }
@@ -398,8 +401,8 @@ public void test16bTransformationDelete() throws Exception {
398401 @ Test
399402 public void test17aTransformationDeleteImplicit () throws Exception {
400403 // should allow deleting implicit transformation
401- api .transformation ("c_scale,w_100" , ObjectUtils .emptyMap ());
402- api .deleteTransformation ("c_scale,w_100" , ObjectUtils .emptyMap ());
404+ api .transformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .emptyMap ());
405+ api .deleteTransformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .emptyMap ());
403406 }
404407
405408 @ Test
@@ -420,7 +423,7 @@ public void test20ResourcesContext() throws Exception {
420423 */
421424 @ Test (expected = NotFound .class )
422425 public void test17bTransformationDeleteImplicit () throws Exception {
423- api .transformation ("c_scale,w_100" , ObjectUtils .emptyMap ());
426+ api .transformation (EXPLICIT_TRANSFORMATION_NAME , ObjectUtils .emptyMap ());
424427 }
425428
426429 @ Test
@@ -556,9 +559,7 @@ public void testGetUploadPreset() throws Exception {
556559 // should allow getting a single upload_preset
557560 String [] tags = {"a" , "b" , "c" };
558561 Map context = ObjectUtils .asMap ("a" , "b" , "c" , "d" );
559- Transformation transformation = new Transformation ();
560- transformation .width (100 ).crop ("scale" );
561- Map result = api .createUploadPreset (ObjectUtils .asMap ("unsigned" , true , "folder" , "folder" , "transformation" , transformation , "tags" , tags , "context" ,
562+ Map result = api .createUploadPreset (ObjectUtils .asMap ("unsigned" , true , "folder" , "folder" , "transformation" , EXPLICIT_TRANSFORMATION , "tags" , tags , "context" ,
562563 context ));
563564 String name = result .get ("name" ).toString ();
564565 Map preset = api .uploadPreset (name , ObjectUtils .emptyMap ());
0 commit comments