Junit - Extending list core component | Community
Skip to main content
New Participant
December 5, 2019
Solved

Junit - Extending list core component

  • December 5, 2019
  • 1 reply
  • 1606 views

Hi All,

I have used delegate pattern to extend list core component in my component sling model.

@Self @Via(type = ResourceSuperType.class)

    private List list;

Collection<ListItem> listItems = list.getListItems();

When i use this pattern, i could not retrieve getter methods from model class in  junit using aem context request object. It throws null pointer exception. Without this, i am able to access it.

Inside setup method:

context.addModelsForClasses(CustomListImpl.class);

  MockitoAnnotations.initMocks(this);

  context.load().json("/com/demo/aem/common/components/CustomListImplTest.json", "/content");

  context.currentResource("/content/customlist");

  CustomList list = context.request().adaptTo(CustomList.class);

list.getParentPage() -> throws null pointer exception. It works fine if i do not use delegate pattern.

Thanks in advance.

Divya

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

aanchal-sikka
aanchal-sikkaAccepted solution
New Participant
October 30, 2023