


Hi ! I'm trying to create a test case JUnit which involves getting the title metadata from image. But so far I can't find any materials or samples of Assets DAM JUnit test cases. Any suggestions will be helpful. Thank you
Views
Replies
Sign in to like this content
Total Likes
Could you give the sample code you are trying to test ? Basically the logic of unit testing is mocking everything you want to test. If you have the correct mocks created , your test should basically pass.
@Veena_Vikram please see below
public String getImageTitle() {
Resource resource = resolver.getResource(imagePath);
Asset asset = resource.adaptTo(Asset.class);
return asset.getMetadataValue("dc:Title");
}
You can create a new asset at "/content/dam/test-image.jpg" with width, height, mime type "image/jpeg" and image title
Example:
Asset asset = context.create().asset("/content/dam/test-image.jpg", 1600, 900, "image/jpeg", "dc:title", "title metadata for image");
Do not need to load a binary and additional json.
Views
Replies
Sign in to like this content
Total Likes