does anyone know how to adopt json resource as asset while writing junit? | Community
Skip to main content
Level 4
Nov 15, 2022 12:11 PM UTC
Solved

does anyone know how to adopt json resource as asset while writing junit?

context.load().json("/my/folder/co/aem/core/workflow/dam/xyz.json", "/content/dam/test/abc.zip");

Resource resource = context.resourceResolver().getResource("/content/dam/test/abc.zip");

Asset asset = resource.adaptTo(Asset.class); //here asset is null

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Nov 16, 2022 12:49 PM UTC

10 replies

arunpatidar
New Participant
Nov 15, 2022 12:17 PM UTC

Please check example

https://github.com/arunpatidar02/com.aemlab.junitapp/tree/master/core/src/test 

jsons are inside resources folder

Translate
Arun Patidar
Level 4
Nov 15, 2022 12:45 PM UTC

Hi Arun,

 

Thanks for your reply. i didnot get any reference.

i'm trying to adapt "resource.adaptTo(Asset.class)" resource as Asset but i'm getting null not sure why this is happening.

Here i'm getting resource.

Translate
arunpatidar
New Participant
Nov 15, 2022 1:57 PM UTC

Can you try to chekc if Resource is null or not?

If Resource is not null then make sure your json contains node type of dam:Asset

I have shared the reference to let you know, how you can created resources using json in your test cases

Translate
Arun Patidar