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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Need help with Junit for the below mentioned WCMUse class : Bit Urgent

askdctm
Level 9
Level 9

Hi All,

public abstract class SampleUse extends WCMUse {

protected List<String> getList(ValueMap resourceProperties) {
        String propertyName = get(Constants.NAME, String.class); 

and so on...

#1] This is like a utility class and has various methods in it, invoked from various places/components. But the requirement is to invoke these methods from SampleUseTest.java even though components are invoking the same code.

#2] The "get" is a WCMUse class, which retrieves arguments passed via sightly [for instance : @ property='Path']. 

#3] From the java code corresponding to the component if "when(bindings.get("property")).thenReturn("Path");" is used then it works fine.

#4] However, when I try the same thing from the above util class, it throws NUllpointer/WCMUse Exception and breaking here.

Any thoughts/pointers on this will be really really helpful.

0 Replies
askdctm
Level 9
Level 9

Hi All,

Any thoughts on this will be helpful.

askdctm
Level 9
Level 9

Hi All,

An additional observation as below :

I can see that when any of the WCMUse related methods[https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/cq/sightly/WCMUse.html#getResou...()]  is being used in the Junit, its failing with Nullpointerexception for those and throwing WCMUseException. However, from other component junit test classes when the same method[i.e, getList() mentioned above]  is called it is working. Not sure where exactly I am going wrong.

askdctm
Level 9
Level 9

Hi All,

Additional observation:

When I "debug as Junit test", just for this junit class it throws message as seen in screenshot. If i click ok for 3-4 times it then goes to debug mode. Did run couple of builds, restarted eclipse, manually placed core bundle[having java code] into system/console/configMgr, but still the same. Has this got anything to do with the errors its throwing for WCMUse methods.