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

Resource is returning Null from Sling Model class in JUnit

Avatar

Avatar
Ignite 1
Level 2
ks_hitijingole
Level 2

Likes

3 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back 3
Give Back
Boost 3
Boost 1
View profile

Avatar
Ignite 1
Level 2
ks_hitijingole
Level 2

Likes

3 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back 3
Give Back
Boost 3
Boost 1
View profile
ks_hitijingole
Level 2

31-05-2021

I have added details of the issue on below link. 

https://stackoverflow.com/questions/67414080/resource-is-returning-null-from-sling-model-class-in-ju...

 

Can you please let me know if I am missing anything.

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

511 likes

Total Posts

647 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

511 likes

Total Posts

647 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

01-06-2021

Hi @ks_hitijingole,

From the log statement, resource named "componentResource" that you are injecting in the model is null. (which is the starting point in the getFaqQuestionAnswerArray() method) because of this it a NPE on getFaqQuestionAnswerArray() method from the test class.

Could you please share your

  • Mock JSON file(pdp.json) and
  • Screenshot of component node structure from CRXDE as available under content path (faqcomponent available under the respective /content path say /content/xyz/page/jcr:content/root/responsivegrid/faqcomponent)

Answers (3)

Answers (3)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,227 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

01-06-2021

Could you please share test json as well?

Avatar

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

112 likes

Total Posts

394 posts

Correct Reply

64 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

112 likes

Total Posts

394 posts

Correct Reply

64 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile
Prince_Shivhare
Level 7

01-06-2021

can you please re-check whatever you are configuring on the dialog is configured on the JSON file?

there should not be any variable miss inside the json.

 

Avatar

Avatar
Give Back 10
MVP
shelly-goel
MVP

Likes

180 likes

Total Posts

337 posts

Correct Reply

88 solutions
Top badges earned
Give Back 10
Validate 1
Shape 1
Ignite 1
Give Back 5
View profile

Avatar
Give Back 10
MVP
shelly-goel
MVP

Likes

180 likes

Total Posts

337 posts

Correct Reply

88 solutions
Top badges earned
Give Back 10
Validate 1
Shape 1
Ignite 1
Give Back 5
View profile
shelly-goel
MVP

01-06-2021

You can go through this tutorial to assert for Arrays

https://www.youtube.com/watch?v=g5x6F8bUHj8