Hi AEM Community,
I have a strange issue when writing a JUnit for my Test class.
This is my custom impl class's code snippet which is being tested -
1. There is an object of Accordion interface
2. We are creating a custom getData method to create a custom analytics layer. As seen below a resource object is created from SlingHttpServletRequest adaptable interface.
The accordion object is used to inherit features from core component's data layer while resource object is used to get JCR data.
This is working fine when being called upon by the Accordion component in a page.
However, when running the same method via Test class as shown below - the accordion object is being returned as null even though it has been mocked!
The mocked accordion object is being created successfully in test class but renders itself as null in impl class.
Is there something amiss with mocking the below object ?
@arunpatidar - Thanks for the link. My scenario differs slightly in below way -
I have 1 custom interface CustomAccordion which is not extending Accordion.
The implementation class for this is using the delegation pattern.
1. defaultInjectionStrategy=DefaultInjectionStrategy.OPTIONAL is already present
2. Use one more adaptable to adapt Core Accordion Component not working. Its gives build error.