Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Junit for CustomPageNameProvider

Avatar

Level 1

We have implemented the custom implementation for the java class CustomPageNameProvider referring below link,

 

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/extending-analytics-pa-naming....

 

And we are facing the challenges while implementing Junit for the CustomPageNameProvider for the below line,

 

Framework framework = context.getFramework();
Resource resource = context.getResource();

 

To get the context object in junit we have implemetated below line but we are unable to get the implementation object for the framework.

 

AnalyticsPageNameContext context = new AnalyticsPageNameContext(configuration, framework, resourceResolver, resource, "adobe", "/content/adobe");

 

We are looking any lead on the framework object on the Junit.

 

test case ,

 

Mockito.when(context.getFramework()).thenReturn(framework); // framework is throwing NullPointerException.

Mockito.when(context.getResource()).thenReturn(resource);
customPageNameProvider.getPageName(context);

 

Any lead would be highly appreciated.

 

Thanks,

Ramesh.

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

I would mock all these classes or create minimal implementations just for mocking purposes, if you need to be more flexible. But I doubt that you can use the product classes directly.

 

Jörg

 

 

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Hi,

I would mock all these classes or create minimal implementations just for mocking purposes, if you need to be more flexible. But I doubt that you can use the product classes directly.

 

Jörg