Unit testing code that sets properties using ModifiableValueMap?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unit testing code that sets properties using ModifiableValueMap?

John Logan
Hi,

I'm writing some unit tests for my code and am trying to use Sling Mocks [1].

My code sets properties using resource.adaptTo(ModifiableValueMap.class), but when used with a MockResource, the call returns null, failing the test.  Is there a recommended way to code unit tests for such cases?

Thanks!  John

[1] https://sling.apache.org/documentation/development/sling-mock.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unit testing code that sets properties using ModifiableValueMap?

John Logan
Hehe...this turned out to be a false alarm.


I had looked at the MockResource code and thought that it was the reason null was coming back, but I looked a little further and found an issue in my code that was causing the problem.  The Sling mock context with the default resource resolver is working fine now.

________________________________
From: John Logan <[hidden email]>
Sent: Friday, April 7, 2017 3:29:33 PM
To: [hidden email]
Subject: Unit testing code that sets properties using ModifiableValueMap?

Hi,

I'm writing some unit tests for my code and am trying to use Sling Mocks [1].

My code sets properties using resource.adaptTo(ModifiableValueMap.class), but when used with a MockResource, the call returns null, failing the test.  Is there a recommended way to code unit tests for such cases?

Thanks!  John

[1] https://sling.apache.org/documentation/development/sling-mock.html
Loading...