Getting below error when JUnit executed for a model.
Is this issue to do with this plugin?
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<executions>
<execution>
<id>bnd-process</id>
<goals>
<goal>bnd-process</goal>
</goals>
<configuration>
<bnd><![CDATA[
Bundle-Category: test-web
Import-Package: javax.annotation;version=0.0.0,com.adobe.cq.wcm.core.components.models;version=0.0.0,*
-exportcontents: ${packages;VERSIONED}
Sling-Model-Packages: com.test-web.core.models
-snapshot: ${tstamp;yyyyMMddHHmmssSSS}
Bundle-DocURL:
-plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
]]></bnd>
</configuration>
</execution>
</executions>
org.reflections.ReflectionsException: Scanner TypeAnnotationsScanner was not configured
at org.reflections.Store.get(Store.java:39)
at org.reflections.Store.get(Store.java:61)
at org.reflections.Store.get(Store.java:46)
at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:429)
at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:416)
at org.apache.sling.testing.mock.sling.context.ModelAdapterFactoryUtil.getModelClassUrlsForPackages(ModelAdapterFactoryUtil.java:149)
at org.apache.sling.testing.mock.sling.context.ModelAdapterFactoryUtil.access$000(ModelAdapterFactoryUtil.java:58)
at org.apache.sling.testing.mock.sling.context.ModelAdapterFactoryUtil$RegisterModelsBundle.findEntries(ModelAdapterFactoryUtil.java:233)
at org.apache.sling.models.impl.ModelPackageBundleListener.addingBundle(ModelPackageBundleListener.java:114)
at org.apache.sling.models.impl.ModelPackageBundleListener.addingBundle(ModelPackageBundleListener.java:52)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
at org.apache.sling.testing.mock.osgi.MockBundleContext.sendBundleEvent(MockBundleContext.java:382)
at org.apache.sling.testing.mock.osgi.MockOsgi.sendBundleEvent(MockOsgi.java:62)
at org.apache.sling.testing.mock.sling.context.ModelAdapterFactoryUtil.addModelsForPackages(ModelAdapterFactoryUtil.java:95)
at org.apache.sling.testing.mock.sling.context.ModelAdapterFactoryUtil.addModelsForManifestEntries(ModelAdapterFactoryUtil.java:128)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.registerDefaultServices(SlingContextImpl.java:196)
at io.wcm.testing.mock.aem.context.AemContextImpl.registerDefaultServices(AemContextImpl.java:72)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:137)
at io.wcm.testing.mock.aem.context.AemContextImpl.setUp(AemContextImpl.java:104)
at io.wcm.testing.mock.aem.junit5.AemContext.setUpContext(AemContext.java:100)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.setAemContextInStore(AemContextExtension.java:73)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.postProcessTestInstance(AemContextExtension.java:63)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassTestDescriptor.java:352)
at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:204)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeTestInstancePostProcessors$7(ClassTestDescriptor.java:352)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeTestInstancePostProcessors(ClassTestDescriptor.java:351)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateAndPostProcessTestInstance(ClassTestDescriptor.java:270)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstancesProvider$2(ClassTestDescriptor.java:259)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstancesProvider$3(ClassTestDescriptor.java:263)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstancesProvider$4(ClassTestDescriptor.java:262)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:98)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:97)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:107)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:107)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:75)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Disconnected from the target VM, address: '127.0.0.1:51817', transport: 'socket'
Process finished with exit code 255
JUnit class
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.factory.ModelFactory;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.logging.Logger;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith({ AemContextExtension.class, MockitoExtension.class })
class TargetDateFundImplTest {
private final AemContext context = new AemContext(ResourceResolverType.JCR_MOCK);
private TargetDateFund targetDateFund;
@BeforeEach
void setUp() {
context.addModelsForClasses(com.test.models.impl.TargetDateFundImpl.class);
context.load().json("/components/teaser/test-content.json", "/content/test");
context.load().json("/components/teaser/test-content-dam.json", "/content/dam/core/images");
context.currentPage("/content/test/teasers");
context.currentResource("/content/test/teasers/jcr:content/root/responsivegrid/teaser-1");
targetDateFund = context.request().adaptTo(TargetDateFund.class);
}
void getFragmentPath() {
assertNotNull(targetDateFund.getFragmentPath());
}
}
test-content.json:
{
"teasers": {
"jcr:primaryType": "cq:Page",
"jcr:content" : {
"jcr:primaryType" : "cq:PageContent",
"jcr:title" : "Teasers Test",
"sling:resourceType": "pi-web/components/structure/genericpage",
"jcr:description" : "Teasers description from <page properties>",
"cq:featuredimage" : {
"jcr:primaryType" : "nt:unstructured",
"jcr:createdBy" : "admin",
"fileReference" : "/content/dam/core/images/Adobe_Systems_logo_and_wordmark.png"
},
"root" : {
"jcr:primaryType" : "nt:unstructured",
"sling:resourceType": "wcm/foundation/components/responsivegrid",
"responsivegrid" : {
"jcr:primaryType" : "nt:unstructured",
"sling:resourceType": "wcm/foundation/components/responsivegrid",
"teaser-1": {
"jcr:primaryType" : "nt:unstructured",
"fileReference" : "/content/dam/core/images/Adobe_Systems_logo_and_wordmark.png",
"jcr:title" : "Teaser",
"titleFromPage": false,
"descriptionFromPage": false,
"jcr:description" : "Description",
"sling:resourceType" : "pi-web/components/content/targetdatefund",
"actions" : {
"jcr:primaryType" : "nt:unstructured",
"item0" : {
"jcr:primaryType" : "nt:unstructured",
"link": "http://www.adobe.com",
"text": "Adobe"
},
"item1" : {
"jcr:primaryType" : "nt:unstructured",
"link": "/content/teasers",
"text": "Teasers"
}
}
},
"teaser-2": {
"jcr:primaryType": "nt:unstructured",
"titleType": "h2",
"jcr:createdBy": "admin",
"jcr:title": "tdf-05152023",
"imageFromPageImage": "false",
"fileReference": "/content/dam/core/images/Adobe_Systems_logo_and_wordmark.png",
"jcr:lastModifiedBy": "admin",
"jcr:created": "Tue May 16 2023 08:43:50 GMT-0700",
"titleFromPage": "false",
"id": "some-id",
"alt": "some alt text",
"jcr:description": "<p>description</p>\r\n",
"jcr:lastModified": "Wed May 17 2023 16:08:41 GMT-0700",
"descriptionFromPage": "false",
"sling:resourceType": "pi-web/components/content/targetdatefund",
"isDecorative": "false",
"textIsRich": "true",
"fragmentPath": "/content/dam/iinvestor/pi-simple-cf-one",
"altValueFromDAM": "false"
}
}
}
}
}
}
test-conent-dam.json
{
"Adobe_Systems_logo_and_wordmark.png": {
"jcr:primaryType": "dam:Asset",
"jcr:mixinTypes" : [
"mix:referenceable"
],
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"jcr:uuid" : "60a1a56e-f3f4-4021-a7bf-ac7a51f0ffe5",
"jcr:content" : {
"jcr:primaryType" : "dam:AssetContent",
"jcr:lastModifiedBy": "admin",
"dam:assetState" : "processed",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:39 GMT+0100",
"dam:relativePath" : "core/images/Adobe_Systems_logo_and_wordmark.png",
"renditions" : {
"jcr:primaryType" : "nt:folder",
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"cq5dam.web.1280.1280.png": {
"jcr:primaryType": "nt:file",
"jcr:createdBy" : "workflow-process-service",
"jcr:created" : "Mon Mar 20 2017 11:20:39 GMT+0100",
"jcr:content" : {
"jcr:primaryType" : "oak:Resource",
"jcr:lastModifiedBy": "workflow-process-service",
"jcr:mimeType" : "image/png",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:39 GMT+0100",
":jcr:data" : 27795
}
},
"original" : {
"jcr:primaryType": "nt:file",
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"jcr:content" : {
"jcr:primaryType" : "oak:Resource",
"jcr:lastModifiedBy": "admin",
"jcr:mimeType" : "image/png",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:37 GMT+0100",
":jcr:data" : 49069
}
}
},
"related" : {
"jcr:primaryType": "nt:unstructured"
},
"metadata" : {
"jcr:primaryType" : "nt:unstructured",
"jcr:mixinTypes" : [
"cq:Taggable"
],
"dam:Physicalheightininches" : "27.77777862548828",
"dam:Physicalwidthininches" : "27.77777862548828",
"dam:Fileformat" : "PNG",
"dam:Progressive" : "no",
"tiff:ImageLength" : 2000,
"dam:extracted" : "Mon Mar 20 2017 11:20:38 GMT+0100",
"dc:format" : "image/png",
"dam:Bitsperpixel" : 8,
"dam:MIMEtype" : "image/png",
"dam:Physicalwidthindpi" : 72,
"dam:Physicalheightindpi" : 72,
"dam:Numberofimages" : 1,
"dam:Numberoftextualcomments": 0,
"tiff:ImageWidth" : 2000,
"dam:sha1" : "bb3aa5c9b452b04808006037911705d3592bfd71",
"dam:size" : 49069
}
}
},
"asset1.png": {
"jcr:primaryType": "dam:Asset",
"jcr:mixinTypes" : [
"mix:referenceable"
],
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"jcr:uuid" : "60a1a56e-f3f4-4021-a7bf-ac7a51f0ffe5",
"jcr:content" : {
"jcr:primaryType" : "dam:AssetContent",
"jcr:lastModifiedBy": "admin",
"dam:assetState" : "processed",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:39 GMT+0100",
"dam:relativePath" : "core/images/Adobe_Systems_logo_and_wordmark.png",
"renditions" : {
"jcr:primaryType" : "nt:folder",
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"cq5dam.web.1280.1280.png": {
"jcr:primaryType": "nt:file",
"jcr:createdBy" : "workflow-process-service",
"jcr:created" : "Mon Mar 20 2017 11:20:39 GMT+0100",
"jcr:content" : {
"jcr:primaryType" : "oak:Resource",
"jcr:lastModifiedBy": "workflow-process-service",
"jcr:mimeType" : "image/png",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:39 GMT+0100",
":jcr:data" : 27795
}
},
"original" : {
"jcr:primaryType": "nt:file",
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"jcr:content" : {
"jcr:primaryType" : "oak:Resource",
"jcr:lastModifiedBy": "admin",
"jcr:mimeType" : "image/png",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:37 GMT+0100",
":jcr:data" : 49069
}
}
},
"related" : {
"jcr:primaryType": "nt:unstructured"
},
"metadata" : {
"jcr:primaryType" : "nt:unstructured",
"jcr:mixinTypes" : [
"cq:Taggable"
],
"dam:Physicalheightininches" : "27.77777862548828",
"dam:Physicalwidthininches" : "27.77777862548828",
"dam:Fileformat" : "PNG",
"dam:Progressive" : "no",
"tiff:ImageLength" : 2000,
"dam:extracted" : "Mon Mar 20 2017 11:20:38 GMT+0100",
"dc:format" : "image/png",
"dam:Bitsperpixel" : 8,
"dam:MIMEtype" : "image/png",
"dam:Physicalwidthindpi" : 72,
"dam:Physicalheightindpi" : 72,
"dam:Numberofimages" : 1,
"dam:Numberoftextualcomments": 0,
"tiff:ImageWidth" : 2000,
"dam:sha1" : "bb3aa5c9b452b04808006037911705d3592bfd71",
"dam:size" : 49069
}
}
},
"asset2.png": {
"jcr:primaryType": "dam:Asset",
"jcr:mixinTypes" : [
"mix:referenceable"
],
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"jcr:uuid" : "60a1a56e-f3f4-4021-a7bf-ac7a51f0ffe5",
"jcr:content" : {
"jcr:primaryType" : "dam:AssetContent",
"jcr:lastModifiedBy": "admin",
"dam:assetState" : "processed",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:39 GMT+0100",
"dam:relativePath" : "core/images/Adobe_Systems_logo_and_wordmark.png",
"renditions" : {
"jcr:primaryType" : "nt:folder",
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"cq5dam.web.1280.1280.png": {
"jcr:primaryType": "nt:file",
"jcr:createdBy" : "workflow-process-service",
"jcr:created" : "Mon Mar 20 2017 11:20:39 GMT+0100",
"jcr:content" : {
"jcr:primaryType" : "oak:Resource",
"jcr:lastModifiedBy": "workflow-process-service",
"jcr:mimeType" : "image/png",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:39 GMT+0100",
":jcr:data" : 27795
}
},
"original" : {
"jcr:primaryType": "nt:file",
"jcr:createdBy" : "admin",
"jcr:created" : "Mon Mar 20 2017 11:20:37 GMT+0100",
"jcr:content" : {
"jcr:primaryType" : "oak:Resource",
"jcr:lastModifiedBy": "admin",
"jcr:mimeType" : "image/png",
"jcr:lastModified" : "Mon Mar 20 2017 11:20:37 GMT+0100",
":jcr:data" : 49069
}
}
},
"related" : {
"jcr:primaryType": "nt:unstructured"
},
"metadata" : {
"jcr:primaryType" : "nt:unstructured",
"jcr:mixinTypes" : [
"cq:Taggable"
],
"dam:Physicalheightininches" : "27.77777862548828",
"dam:Physicalwidthininches" : "27.77777862548828",
"dam:Fileformat" : "PNG",
"dam:Progressive" : "no",
"tiff:ImageLength" : 2000,
"dam:extracted" : "Mon Mar 20 2017 11:20:38 GMT+0100",
"dc:format" : "image/png",
"dam:Bitsperpixel" : 8,
"dam:MIMEtype" : "image/png",
"dam:Physicalwidthindpi" : 72,
"dam:Physicalheightindpi" : 72,
"dam:Numberofimages" : 1,
"dam:Numberoftextualcomments": 0,
"tiff:ImageWidth" : 2000,
"dam:sha1" : "bb3aa5c9b452b04808006037911705d3592bfd71",
"dam:size" : 49069
}
}
}
}
Model interface, class
public interface TargetDateFund extends Teaser, ContainerExporter {
/**
* Returns this teaser's hedge text fragment path, if one was defined.
*/
default String getFragmentPath() {
return null;
}
/**
* Returns this teaser's hedge text from content fragment , if one was defined.
*/
default String getHedgeText() { return null;}
}
@Model(
adaptables = {SlingHttpServletRequest.class},
adapters = {Teaser.class, TargetDateFund.class, ComponentExporter.class},
resourceType = {TargetDateFundImpl.RESOURCE_TYPE},
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME , extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class TargetDateFundImpl implements TargetDateFund
{
protected static final String RESOURCE_TYPE = "pi-web/components/content/targetdatefund";
@SlingObject
private ResourceResolver resourceResolver;
@Self
@Required
private SlingHttpServletRequest request;
@Self
@Via(type = ResourceSuperType.class)
private com.adobe.cq.wcm.core.components.models.Teaser teaser;
@ScriptVariable
private ValueMap properties;
@Inject
private ModelFactory modelFactory;
@Inject
private SlingModelFilter slingModelFilter;
private String fragmentPath;
private String hedgeText;
private Map<String, ComponentExporter> childModels = null;
@PostConstruct
protected void initModel() {
fragmentPath = properties.get("fragmentPath", String.class);
if (StringUtils.isNotEmpty(fragmentPath)) {
Resource fragmentResource = resourceResolver.getResource(fragmentPath);
if (fragmentResource != null) {
Optional<ContentFragment> contentFragment = Optional.ofNullable(fragmentResource.adaptTo(ContentFragment.class));
hedgeText = contentFragment.map(cf -> cf.getElement("main")).map(ContentElement::getContent)
.orElse(org.apache.commons.lang.StringUtils.EMPTY);
}
}
}
@Override
public String getFragmentPath() {
return fragmentPath;
}
@Override
public String getHedgeText() { return hedgeText; }
/** properties extended from teaser**/
@Override
public boolean isActionsEnabled() {
return teaser.isActionsEnabled();
}
@Override
public List<ListItem> getActions() {
return teaser.getActions();
}
@Override
public Link getLink() {
return teaser.getLink();
}
@Override
public String getLinkURL() {
return teaser.getLinkURL();
}
@Override
public Resource getImageResource() {
return teaser.getImageResource();
}
@Override
public boolean isImageLinkHidden() {
return teaser.isImageLinkHidden();
}
@Override
public String getPretitle() {
return teaser.getPretitle();
}
@Override
public String getTitle() {
return teaser.getTitle();
}
@Override
public boolean isTitleLinkHidden() {
return teaser.isTitleLinkHidden();
}
@Override
public String getDescription() {
return teaser.getDescription();
}
@Override
public String getTitleType() {
return teaser.getTitleType();
}
@Override
public String getId() {
return teaser.getId();
}
@Override
public ComponentData getData() {
return teaser.getData();
}
@Override
public String getAppliedCssClasses() {
return teaser.getAppliedCssClasses();
}
@Override
public String getExportedType() {
return TargetDateFundImpl.RESOURCE_TYPE;
}
@NotNull
@Override
public Map<String, ? extends ComponentExporter> getExportedItems() {
if (childModels == null) {
childModels = getChildModels(request, ComponentExporter.class);
}
return childModels;
}
@NotNull
@Override
public String[] getExportedItemsOrder() {
Map<String, ? extends ComponentExporter> models = getExportedItems();
if (models.isEmpty()) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
return models.keySet().toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
/**
* Returns a map (resource name => Sling Model class) of the given resource
* children's Sling Models that can be adapted to {@link T}.
*
* slingRequest the current request
* modelClass the Sling Model class to be adapted to
* a map (resource name => Sling Model class) of the given resource
* children's Sling Models that can be adapted to {@link T}
*/
@NotNull
private <T> Map<String, T> getChildModels(@NotNull SlingHttpServletRequest slingRequest,
Class<T> modelClass) {
Map<String, T> itemWrappers = new LinkedHashMap<>();
for (final Resource child : slingModelFilter.filterChildResources(request.getResource().getChildren())) {
itemWrappers.put(child.getName(), modelFactory.getModelFromWrappedRequest(slingRequest, child, modelClass));
}
return itemWrappers;
}
/** END exptended proeprties **/
}
Any help appreciated. Not sure, what is going on with this simple junit.
Thanks,
Sri
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @sreenu539 ,
If you are using a reflection java API, try to use the version above 0.10. Earlier to 0.10 version had this and it got fixed in 0.10.
Please check the below thread for more details:
https://stackoverflow.com/questions/60559501/scanner-typeannotationsscanner-was-not-configured-when-...
https://github.com/ronmamo/reflections/issues/273
Are you using reflection java api in your test?
Hi @sreenu539 ,
If you are using a reflection java API, try to use the version above 0.10. Earlier to 0.10 version had this and it got fixed in 0.10.
Please check the below thread for more details:
https://stackoverflow.com/questions/60559501/scanner-typeannotationsscanner-was-not-configured-when-...
https://github.com/ronmamo/reflections/issues/273
Views
Likes
Replies