Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM Assets JUnit Java Sample


Level 1

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 

2 Replies


Community Advisor

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. 


Level 1

@Veena_Vikram please see below


public String getImageTitle() {
Resource resource = resolver.getResource(imagePath);
Asset asset = resource.adaptTo(Asset.class);
return asset.getMetadataValue("dc:Title");