@@ -762,6 +762,35 @@ public void testPublishByIds() throws Exception {
762762 cloudinary .uploader ().destroy (publicId , null );
763763 }
764764
765+ @ Test
766+ public void testPublishWithType () throws Exception {
767+ Map response = cloudinary .uploader ().upload (SRC_TEST_IMAGE , ObjectUtils .asMap ("tags" , uniqueTag , "type" , "authenticated" ));
768+ String publicId = (String ) response .get ("public_id" );
769+
770+ // publish with wrong type - verify publish fails
771+ response = cloudinary .api ().publishByIds (Arrays .asList (publicId ), ObjectUtils .asMap ("type" , "private" ));
772+ List published = (List ) response .get ("published" );
773+ List failed = (List ) response .get ("failed" );
774+ assertNotNull (published );
775+ assertNotNull (failed );
776+ assertEquals (published .size (), 0 );
777+ assertEquals (failed .size (), 1 );
778+
779+ // publish with correct type - verify publish succeeds
780+ response = cloudinary .api ().publishByIds (Arrays .asList (publicId ), ObjectUtils .asMap ("type" , "authenticated" ));
781+ published = (List ) response .get ("published" );
782+ failed = (List ) response .get ("failed" );
783+ assertNotNull (published );
784+ assertNotNull (failed );
785+ assertEquals (published .size (), 1 );
786+ assertEquals (failed .size (), 0 );
787+
788+ Map resource = (Map ) published .get (0 );
789+ assertEquals (resource .get ("public_id" ), publicId );
790+ assertNotNull (resource .get ("url" ));
791+ cloudinary .uploader ().destroy (publicId , null );
792+ }
793+
765794 @ Test
766795 public void testPublishByPrefix () throws Exception {
767796 Map response = cloudinary .uploader ().upload (SRC_TEST_IMAGE , ObjectUtils .asMap ("tags" , uniqueTag , "type" , "authenticated" ));
0 commit comments