Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Unit Test for SlingQuery

Avatar

Avatar
Give Back
Level 1
troubleshooter3
Level 1

Like

1 like

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile

Avatar
Give Back
Level 1
troubleshooter3
Level 1

Like

1 like

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile
troubleshooter3
Level 1

26-05-2021

How can I write a unit test to test below Sling Query from my code.

 

List<Resource> legalDisclaimerResourceList = $(legalDisclaimerPageResource).find(LEGAL_DISCLAIMER).asList();

 

$ refers to Sling Query from 

import static org.apache.sling.query.SlingQuery.$;

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

505 likes

Total Posts

641 posts

Correct Reply

213 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

505 likes

Total Posts

641 posts

Correct Reply

213 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile
Vijayalakshmi_S
MVP

27-05-2021

Hi @troubleshooter3,

Per the official Sling docs, Mock implementation for Sling Query is not available in the list of Selected Sling APIs (for which the mock is available)

https://sling.apache.org/documentation/development/sling-mock.html

 

Answers (0)