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();
childPageResource
String toutStyle = assetStyles.stream().collect(Collectors.joining(","));
//log.error("toutStyle {}", toutStyle);
//adding style property to the resource*/
try{
ModifiableValueMap properties = childPageResource.adaptTo(ModifiableValueMap.class);
properties.put("dummyStyle", toutStyle); //write
resourceResolver.commit();
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
@Test
public void testShopStylesException() throws Exception, LoginException {
Set<String> listStyles;
Resource resource = resourceResolver.getResource(seasonPagePath);
Page seasonPage = resource.adaptTo(Page.class);
when(currentPage.getAbsoluteParent(2)).thenReturn(seasonPage);
when(shopLookupService.fetchShopCodes(anyString(),anyString(),anyString())).thenThrow(IOException.class);
//smartTile.activate();
listStyles = smartTile.getShopStyleCodeList();
assertTrue(listStyles.isEmpty());
}
Thanks in Advance, Appreciate your help