Regarding the junit testing in sightly based components
Hi,
I am facing the problem with junit testing for sightly based components can you people please suggest how to write the test cases for below code which i mentioned?
public void activate() throws Exception {
LOGGER.info("Class : " + this.getClass().getName()
+ " : Method : activate() : [Start]");
bioDetailsBean = new BioDetailsBean();
String prsnInfoPath = getProperties().get(
BioDetailsConstants.PERSON_DETAILS, String.class);
Session session = getResourceResolver().adaptTo(Session.class);
try {
Node node = session.getNode(prsnInfoPath);
String description = getProperties().get(
BioDetailsConstants.JCR_DESCRIPTION, String.class);
String introText = getProperties().get(
BioDetailsConstants.JCR_INTROTEXT, String.class);
String firstName = node
.getProperty(BioDetailsConstants.JCR_FSTNAME).getValue()
.getString();
String image = node.getProperty(BioDetailsConstants.JCR_IMAGE)
.getValue().getString();
String recrtUniv = node
.getProperty(BioDetailsConstants.JCR_RECRTUNIV).getValue()
.getString();
String title = node.getProperty(BioDetailsConstants.JCR_TITLE)
.getValue().getString();
bioDetailsBean.setDescription(description);
bioDetailsBean.setFirstName(firstName);
bioDetailsBean.setImage(image);
bioDetailsBean.setIntroText(introText);
bioDetailsBean.setRecrtUniv(recrtUniv);
bioDetailsBean.setTitle(title);
} catch (PathNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LOGGER.info("Class : " + this.getClass().getName()
+ " : Method : activate() : [End]");
}
And i am getting the problem like how to call my controller methods in test class using mock objects
Ex: when(wcmuse_mock.getProperties()).thenReturn(V_MOCK); ?