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 for CustomPageNameProvider

Avatar

Avatar
Level 1
rsonth
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
rsonth
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
rsonth
Level 1

28-08-2020

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.

 

 

 

AEM Junit

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,133 likes

Total Posts

3,161 posts

Correct Reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,133 likes

Total Posts

3,161 posts

Correct Reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

29-08-2020

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

 

 

Answers (0)