use of org.survey.model.poll.Poll in project survey by markoniemi.
the class EditPollBeanTest method addPollWithError.
@Test
public void addPollWithError() {
String result = editPollBean.addPoll();
Assert.assertEquals("editPollBean.addPoll returned an unexpected value", "editPoll", result);
Poll createdPoll = new Poll("poll");
editPollBean.setPoll(createdPoll);
result = editPollBean.savePoll();
Assert.assertEquals("editPollBean.savePoll returned an unexpected value", "pollSaved", result);
Poll pollFromDatabase = pollService.findOne(createdPoll.getName());
Assert.assertNotNull("registered poll was not added to database", pollFromDatabase);
Assert.assertEquals("poll", pollFromDatabase.getName());
result = editPollBean.addPoll();
createdPoll.setId(null);
editPollBean.setPoll(createdPoll);
result = editPollBean.savePoll();
Assert.assertNull(result);
Assert.assertEquals("Poll with this name already exists.", editPollBean.getMessage());
}
use of org.survey.model.poll.Poll in project survey by markoniemi.
the class EditPollBeanTest method tearDown.
@After
public void tearDown() {
Poll[] polls = pollService.findAll();
for (Poll poll : polls) {
pollService.delete(poll.getName());
}
userService.delete(this.user.getUsername());
}
use of org.survey.model.poll.Poll in project survey by markoniemi.
the class EditPollBeanTest method questionTypeChanged.
@Ignore("poll is attached and test does not represent the situation in runtime")
@Test
public void questionTypeChanged() {
// addQuestion calls addPoll
addQuestion();
editPollBean.getPoll().getQuestions().get(0).setType(QuestionType.BOOLEAN);
editPollBean.questionTypeChanged(0);
String result = editPollBean.savePoll();
Assert.assertEquals("editPollBean.savePoll returned an unexpected value", "pollSaved", result);
Poll pollFromDatabase = pollService.findOne("poll");
QuestionType type = pollFromDatabase.getQuestions().get(0).getType();
Assert.assertEquals(QuestionType.BOOLEAN, type);
}
use of org.survey.model.poll.Poll in project survey by markoniemi.
the class EditPollBeanTest method addPoll.
@Test
public void addPoll() {
String result = editPollBean.addPoll();
Assert.assertEquals("editPollBean.register returned an unexpected value", "editPoll", result);
// Poll createdPoll = new Poll("poll");
// editPollBean.setPoll(createdPoll);
editPollBean.getPoll().setName("poll");
result = editPollBean.savePoll();
Assert.assertEquals("editPollBean.savePoll returned an unexpected value", "pollSaved", result);
Poll pollFromDatabase = pollService.findOne("poll");
Assert.assertNotNull("registered poll was not added to database", pollFromDatabase);
Assert.assertEquals("poll", pollFromDatabase.getName());
}
use of org.survey.model.poll.Poll in project survey by markoniemi.
the class PollController method editPoll.
@RequestMapping(value = "/poll/{name}", method = RequestMethod.GET)
public ModelAndView editPoll(@PathVariable String name) {
Poll poll = pollService.findOne(name);
log.debug("editPoll() - found poll: " + poll);
if (poll == null) {
poll = new Poll();
}
ModelAndView model = new ModelAndView();
model.setViewName("/poll/poll");
model.addObject("poll", poll);
return model;
}
Aggregations