Junit for sling models based on Delegation Pattern | Community
Skip to main content
January 24, 2023
Solved

Junit for sling models based on Delegation Pattern

  • January 24, 2023
  • 1 reply
  • 1947 views
Hi Team,
 
We are trying to create junit for sling models where delegate pattern was used, but the core class reference always returns null.Is there any better way to create junit for such use case. Detailed error : java.lang.NullPointerException: Cannot invoke "com.adobe.cq.wcm.core.components.models.Navigation.getAccessibilityLabel()" because "this.navigation" is null.
 
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by nitesh_kumar-1

Hi @nehama ,

 

You can check the WKND project example for ImageList, It injects "com.adobe.cq.wcm.core.components.models.List" 

https://github.com/adobe/aem-guides-wknd/blob/main/core/src/test/java/com/adobe/aem/guides/wknd/core/models/impl/ImageListImplTest.java 

 

Hope this helps!

 

Regards,

Nitesh

1 reply

nitesh_kumar-1
Adobe Employee
nitesh_kumar-1Adobe EmployeeAccepted solution
Adobe Employee
January 24, 2023

Hi @nehama ,

 

You can check the WKND project example for ImageList, It injects "com.adobe.cq.wcm.core.components.models.List" 

https://github.com/adobe/aem-guides-wknd/blob/main/core/src/test/java/com/adobe/aem/guides/wknd/core/models/impl/ImageListImplTest.java 

 

Hope this helps!

 

Regards,

Nitesh

NehaMaAuthor
January 24, 2023

hi @nitesh_kumar-1 - Let us try once and get back

NehaMaAuthor
February 1, 2023

hi @nitesh_kumar-1 - Tried but getting null pointer for imagelist core as well, can you check or have any working sample to be shared.