Hey People. I have been recently validating Struts 2 actions. In One of my action class, the save method to be precise must have two id s. That is an assessmenttype id and a course id. this is what is have so far.
@Test
public void testSave() {
Assessment assessment = new Assessment();
assessment.setAssessmentType(assessment.getAssessmentType());
assessment.setCourse(assessment.getCourse());
assessment.setAmount(2);
assessment.setDescription("A test Description");
assessment.setPercentage(20.0);
action.setAssessment(assessment);
action.save();
assertNotNull(action.getAssessment().getId());
}
all help would be appreciated.
Hey Sorry peeps, i taught i asked the question. But what i am trying to really achive is to the test the action class that i have for assessment. For instance if the client uses the application when adding an assessment, the course id is hidden from the user but to save an assessment it must exist. also to save the assessment they have a select an assessmenttype. therefore for the save method to work perfectly both course id and assessmenttype it must exist.
The question therefore is that i don t really know how to test and implement the course id as well as assessmenttype id.
Thanks again. all help would be appreciated
The Save Action method is described below;
public String save(){
if (cancel != null) {
return "cancel";
}
boolean isNew = (assessment.getId() == null);
assessmentType.addAssessment(assessment);
course.addAssessment(assessment);
assessment = assessmentManager.save(assessment);
return "save";
}