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
BedrockMission!

Learn More

View all

Sign in to view all badges

Junit - Extending list core component

Avatar

Avatar
Validate 1
Level 2
divyas70997717
Level 2

Like

1 like

Total Posts

31 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Validate 1
Level 2
divyas70997717
Level 2

Like

1 like

Total Posts

31 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back
View profile
divyas70997717
Level 2

05-12-2019

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

Accepted Solutions (0)

Answers (0)