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

JUnit Mock Test Case for Node Property

Level 5
Level 5

Hi All,

Need a help to write a test case to check node property

Below is the method which is adding a property to the node

public Map addStyleProperty( List<String> assetStyles,Resource childToutNode){

Resource childPageResource = childToutNode.getParent();


String toutStyle =","));

//log.error("toutStyle {}", toutStyle);

//adding style property to the resource*/


ModifiableValueMap properties = childPageResource.adaptTo(ModifiableValueMap.class);

properties.put("dummyStyle", toutStyle); //write


return properties;


catch(Exception e){

log.error("Unable to add the style property to the resource {} with exception {}", childPageResource,e);



for this need to write a test case, please help me if any modification required in above let me know.

Below is the code for reference


    public void testShopStylesException() throws  Exception, LoginException {

        Set<String> listStyles;

        Resource resource = resourceResolver.getResource(seasonPagePath);

        Page seasonPage = resource.adaptTo(Page.class);




        listStyles = smartTile.getShopStyleCodeList();



Thanks in Advance, Appreciate your help

0 Replies