Skip to content
Advertisement

Tag: sling

“resource.adaptTo” NullPointer Unit test AEM Sling Model Java

I’m doing a pretty basic Unit test for Sling Model in AEM, so, when I run the test I get the following error: [ERROR] CtaModelTest.testGetText:36 NullPointer This is my Java code, the Model is a very basic Sling AEM Model, I’m using the @ModelAnnotation as follow: Can anyone help me to fix it? Answer It seems that resource.adaptTo(CtaModel.class) returned null.

Advertisement