does anyone know how to adopt json resource as asset while writing junit? | Community
Skip to main content
Level 4
November 15, 2022
Solved

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

  • November 15, 2022
  • 1 reply
  • 1868 views

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.

1 reply

arunpatidar
Community Advisor
Community Advisor
November 15, 2022

Please check example

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

jsons are inside resources folder

Arun Patidar
Level 4
November 15, 2022

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.

arunpatidar
Community Advisor
Community Advisor
November 15, 2022

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

Arun Patidar