Skip to content

Commit

Permalink
MockAssetDelivery has a new package and different URL
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 19, 2024
1 parent e26ea5b commit 1c67cd8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void assertMedia(Resource resource, Media media, int width, int height, String m

if (!StringUtils.contains(mediaUrl, ".download_attachment.")
&& !StringUtils.contains(mediaUrl, "/is/image/")
&& !StringUtils.contains(mediaUrl, "/asset/delivery/")) {
&& !StringUtils.contains(mediaUrl, "/adobe/dynamicmedia/deliver/")) {
Rendition rendition = media.getRendition();
String strippedMediaUrl = StringUtils.removeEnd(mediaUrl, DynamicMediaPath.DOWNLOAD_SUFFIX);
assertEquals(FilenameUtils.getName(strippedMediaUrl), rendition.getFileName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
*/
package io.wcm.handler.media.impl;

import static io.wcm.testing.mock.aem.dam.MockAssetDelivery.getAssetId;
import static io.wcm.testing.mock.aem.dam.ngdm.MockAssetDelivery.getAssetId;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.day.cq.dam.api.Asset;

import io.wcm.testing.mock.aem.dam.MockAssetDelivery;
import io.wcm.testing.mock.aem.dam.ngdm.MockAssetDelivery;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import io.wcm.wcm.commons.contenttype.ContentType;

Expand All @@ -49,7 +49,7 @@ void setUp() {
void testAsset_JPEG_Original() {
Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG);
buildAssertMedia(asset, 100, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85",
ContentType.JPEG);
}

Expand All @@ -67,7 +67,7 @@ void testAsset_JPEG_Original_WebOptimizedImageDeliveryDisabled() {
void testAsset_JPEG_Rescale() {
Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG);
buildAssertMedia_Rescale(asset, 80, 40,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85&width=80",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85&width=80",
ContentType.JPEG);
}

Expand All @@ -76,7 +76,7 @@ void testAsset_JPEG_Rescale() {
void testAsset_JPEG_AutoCrop() {
Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG);
buildAssertMedia_AutoCrop(asset, 50, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
ContentType.JPEG);
}

Expand All @@ -85,7 +85,7 @@ void testAsset_JPEG_AutoCrop() {
void testAsset_JPEG_AutoCrop_ImageQuality() {
Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG);
buildAssertMedia_AutoCrop(asset, 50, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=60&width=50",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=60&width=50",
ContentType.JPEG, 0.6d);
}

Expand All @@ -95,7 +95,7 @@ void testAsset_JPEG_CropWithExplicitRendition() {
Asset asset = createSampleAsset("/filetype/sample.jpg", ContentType.JPEG);
context.create().assetRendition(asset, "square.jpg", 50, 50, ContentType.JPEG);
buildAssertMedia_AutoCrop(asset, 50, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
ContentType.JPEG);
}

Expand All @@ -104,7 +104,7 @@ void testAsset_JPEG_CropWithExplicitRendition() {
void testAsset_GIF_Original() {
Asset asset = createSampleAsset("/filetype/sample.gif", ContentType.GIF);
buildAssertMedia(asset, 100, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.gif?preferwebp=true&quality=85",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.gif?preferwebp=true&quality=85",
ContentType.GIF);
}

Expand All @@ -113,7 +113,7 @@ void testAsset_GIF_Original() {
void testAsset_GIF_Rescale() {
Asset asset = createSampleAsset("/filetype/sample.gif", ContentType.GIF);
buildAssertMedia_Rescale(asset, 80, 40,
"/asset/delivery/" + getAssetId(asset) + "/sample.gif?preferwebp=true&quality=85&width=80",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.gif?preferwebp=true&quality=85&width=80",
ContentType.GIF);
}

Expand All @@ -122,7 +122,7 @@ void testAsset_GIF_Rescale() {
void testAsset_GIF_AutoCrop() {
Asset asset = createSampleAsset("/filetype/sample.gif", ContentType.GIF);
buildAssertMedia_AutoCrop(asset, 50, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.gif?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.gif?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
ContentType.GIF);
}

Expand All @@ -131,7 +131,7 @@ void testAsset_GIF_AutoCrop() {
void testAsset_PNG_Original() {
Asset asset = createSampleAsset("/filetype/sample.png", ContentType.PNG);
buildAssertMedia(asset, 100, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.png?preferwebp=true&quality=85",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.png?preferwebp=true&quality=85",
ContentType.PNG);
}

Expand All @@ -140,7 +140,7 @@ void testAsset_PNG_Original() {
void testAsset_PNG_Rescale() {
Asset asset = createSampleAsset("/filetype/sample.png", ContentType.PNG);
buildAssertMedia_Rescale(asset, 80, 40,
"/asset/delivery/" + getAssetId(asset) + "/sample.png?preferwebp=true&quality=85&width=80",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.png?preferwebp=true&quality=85&width=80",
ContentType.PNG);
}

Expand All @@ -149,7 +149,7 @@ void testAsset_PNG_Rescale() {
void testAsset_PNG_AutoCrop() {
Asset asset = createSampleAsset("/filetype/sample.png", ContentType.PNG);
buildAssertMedia_AutoCrop(asset, 50, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.png?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.png?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
ContentType.PNG);
}

Expand All @@ -158,7 +158,7 @@ void testAsset_PNG_AutoCrop() {
void testAsset_TIFF_Original() {
Asset asset = createSampleAsset("/filetype/sample.tif", ContentType.TIFF);
buildAssertMedia(asset, 100, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85",
ContentType.JPEG);
}

Expand All @@ -167,7 +167,7 @@ void testAsset_TIFF_Original() {
void testAsset_TIFF_Rescale() {
Asset asset = createSampleAsset("/filetype/sample.tif", ContentType.TIFF);
buildAssertMedia_Rescale(asset, 80, 40,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85&width=80",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?preferwebp=true&quality=85&width=80",
ContentType.JPEG);
}

Expand All @@ -176,7 +176,7 @@ void testAsset_TIFF_Rescale() {
void testAsset_TIFF_AutoCrop() {
Asset asset = createSampleAsset("/filetype/sample.tif", ContentType.TIFF);
buildAssertMedia_AutoCrop(asset, 50, 50,
"/asset/delivery/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
"/adobe/dynamicmedia/deliver/" + getAssetId(asset) + "/sample.jpg?c=25%2C0%2C50%2C50&preferwebp=true&quality=85&width=50",
ContentType.JPEG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import io.wcm.handler.mediasource.dam.impl.metadata.AssetSynchonizationService;
import io.wcm.handler.mediasource.dam.impl.metadata.RenditionMetadataListenerService;
import io.wcm.sling.commons.adapter.AdaptTo;
import io.wcm.testing.mock.aem.dam.MockAssetDelivery;
import io.wcm.testing.mock.aem.dam.ngdm.MockAssetDelivery;
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import io.wcm.wcm.commons.contenttype.ContentType;
Expand Down Expand Up @@ -139,7 +139,7 @@ void testOriginal_WebOptimizedImageDelivery() {
.build();

assertUriTemplate(media.getRendition(), SCALE_WIDTH, 192, 120,
"/asset/delivery/" + assetId + "/sample.jpg?preferwebp=true&quality=85&width={width}");
"/adobe/dynamicmedia/deliver/" + assetId + "/sample.jpg?preferwebp=true&quality=85&width={width}");
assertUriTemplate(media.getRendition(), SCALE_HEIGHT, 192, 120,
"/content/dam/folder1/sample.jpg/_jcr_content/renditions/original.image_file.0.{height}.file/sample.jpg");
}
Expand Down Expand Up @@ -184,7 +184,7 @@ void test4_3_WebOptimizedImageDelivery() {
.build();

assertUriTemplate(media.getRendition(), SCALE_WIDTH, 160, 120,
"/asset/delivery/" + assetId + "/sample.jpg?c=16%2C0%2C160%2C120&preferwebp=true&quality=85&width={width}");
"/adobe/dynamicmedia/deliver/" + assetId + "/sample.jpg?c=16%2C0%2C160%2C120&preferwebp=true&quality=85&width={width}");
assertUriTemplate(media.getRendition(), SCALE_HEIGHT, 160, 120,
"/content/dam/folder1/sample.jpg/_jcr_content/renditions/original.image_file.0.{height}.16,0,176,120.file/sample.jpg");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import io.wcm.handler.media.MediaHandler;
import io.wcm.handler.media.testcontext.AppAemContext;
import io.wcm.sling.commons.adapter.AdaptTo;
import io.wcm.testing.mock.aem.dam.MockAssetDelivery;
import io.wcm.testing.mock.aem.dam.ngdm.MockAssetDelivery;
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import io.wcm.wcm.commons.contenttype.ContentType;
Expand Down Expand Up @@ -111,9 +111,9 @@ void testGetUriTemplate_WebOptimizedImageDelivery() {
Media media = mediaHandler.get(asset.getPath()).build();

assertUriTemplate(media, CROP_CENTER, 100, 50,
"/asset/delivery/" + assetId + "/sample.jpg?preferwebp=true&quality=85&width={width}");
"/adobe/dynamicmedia/deliver/" + assetId + "/sample.jpg?preferwebp=true&quality=85&width={width}");
assertUriTemplate(media, SCALE_WIDTH, 100, 50,
"/asset/delivery/" + assetId + "/sample.jpg?preferwebp=true&quality=85&width={width}");
"/adobe/dynamicmedia/deliver/" + assetId + "/sample.jpg?preferwebp=true&quality=85&width={width}");
assertUriTemplate(media, SCALE_HEIGHT, 100, 50,
"/content/dam/sample.jpg/_jcr_content/renditions/original.image_file.0.{height}.file/sample.jpg");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.day.cq.dam.api.Asset;

import io.wcm.handler.media.CropDimension;
import io.wcm.testing.mock.aem.dam.MockAssetDelivery;
import io.wcm.testing.mock.aem.dam.ngdm.MockAssetDelivery;
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import io.wcm.wcm.commons.contenttype.ContentType;
Expand Down Expand Up @@ -76,10 +76,10 @@ void testGetDeliveryUrl_AssetDeliveryPresent() {
Asset asset = context.create().asset("/content/dam/Test_1.jpg", 10, 10, ContentType.JPEG);
String assetId = MockAssetDelivery.getAssetId(asset);

assertEquals("/asset/delivery/" + assetId + "/test-1.jpg?preferwebp=true",
assertEquals("/adobe/dynamicmedia/deliver/" + assetId + "/test-1.jpg?preferwebp=true",
underTest.getDeliveryUrl(asset, new WebOptimizedImageDeliveryParams()));

assertEquals("/asset/delivery/" + assetId + "/test-1.jpg?c=0%2C0%2C2%2C4&preferwebp=true&r=90&width=10",
assertEquals("/adobe/dynamicmedia/deliver/" + assetId + "/test-1.jpg?c=0%2C0%2C2%2C4&preferwebp=true&r=90&width=10",
underTest.getDeliveryUrl(asset, new WebOptimizedImageDeliveryParams()
.width(10L).cropDimension(new CropDimension(0, 0, 2, 4)).rotation(90)));
}
Expand Down

0 comments on commit 1c67cd8

Please sign in to comment.