I am writing Junit test cases for my classes extending WCMUsePojo but I am not able to mock the value of getProperties() method which returns a Value Map. As a result I get null pointer exception whenever we fetch any key from the Value map. Can anybody help.
Asked
Active
Viewed 769 times
0
-
1Can you post your code? Both the `WCMUsePojo` class and the test. It's difficult to tell what you're doing wrong without seeing it. – toniedzwiedz Sep 28 '18 at 07:15
-
Apart from the code, testing WCMUsePojo is quite difficult, see here: https://stackoverflow.com/questions/45644055/unit-test-wcmusepojo-class – Dawid Pura Sep 30 '18 at 06:12
1 Answers
0
Create a ValueMap with mock values. When you are mocking getProperties() method then return your mock ValueMap.
ValueMap mockValueMap = new ValueMapDecorator(new HashMap());
mockValueMap.put("test", "value");

Bhavika
- 1
- 1