MockComponent `getResourcetype()` method returns incorrect value

Description

The method MockComponent#getResourceType() returns the resource type of the resource used to construct the MockComponent - via Resource#getResourceType.

However, in actual use, the real Component implementation will only return the value of the sling:resourceType property if that property is set. Otherwise it will return the path of the resource, unless that path starts with a search path, in which case it will return the path of the resource with the search path removed.

It does not return the resource type as defined by Resource#getResourceType(), which will return the primary type if the sling:resourceType property is not defined. I do not believe there is any scenario under which the real implementation will return the primary type.

I believe the correct implementation of this method is something like this:

MockComponent.java:

Activity

Show:
Stefan Seifert
November 20, 2020, 4:17 PM

thanks for the PR - looks good, it think the new behavior is correct

Stefan Seifert
November 20, 2020, 4:17 PM
Fixed

Assignee

Stefan Seifert

Reporter

Kyle Giovannetti

Labels

None

Components

Fix versions

Affects versions

Priority

Major
Configure