it's still a problem, How to Unit test case for Sling delegation pattern?
It's still a problem. I am using the latest AEM Maven Archetype to customize the Teaser component, but unable to pass my tests because of the delegation pattern. I scaveraged through the net and have already reviewed all the possible answers like:
@arunpatidar and other folks, can you please help me out by giving me a working version of a Delegation pattern?
Here's a very simple sling model component that needs JUNIT5. I am also on the latest AEM 6.5 version + Latest AEM Maven Archetype version
@Model(adaptables = SlingHttpServletRequest.class, resourceType = CustomTeaser.RESOURCE_TYPE,
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class CustomTeaser implements com.adobe.cq.wcm.core.components.models.Teaser {
public static final String RESOURCE_TYPE = "mycomp/components/customteaser";
@Self
@Via(type = ResourceSuperType.class)
private com.adobe.cq.wcm.core.components.models.Teaser teaser;
@Override
public String getTitle() {
return teaser.getTitle();
}
}
Whenever I am using AEMContext or Mocks, while in debug mode, teaser is ALWAYS NULL.