Skip to content

Commit 4570326

Browse files
authored
Add test for context metadata as user variables (#223)
1 parent a5cda7b commit 4570326

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cloudinary-core/src/test/java/com/cloudinary/TransformationTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,16 @@ public void testUserVariableNamesContainingPredefinedNamesAreNotAffected() {
288288

289289
assertEquals("$aheight_300,$mywidth_100/h_3_mul_ih_add_$aheight,w_3_add_$mywidth_mul_3_add_4_div_2_mul_iw_mul_$mywidth", t.generate());
290290
}
291+
292+
@Test
293+
public void testContextMetadataToUserVariables() {
294+
Transformation t = new Transformation()
295+
.variable("$xpos", "ctx:!x_pos!_to_f")
296+
.variable("$ypos", "ctx:!y_pos!_to_f")
297+
.crop("crop")
298+
.x("$xpos * w")
299+
.y("$ypos * h");
300+
301+
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+
}
291303
}

0 commit comments

Comments
 (0)