Package com.agiletec.plugins.jpsurvey.aps.system.services.survey.model

Examples of com.agiletec.plugins.jpsurvey.aps.system.services.survey.model.Survey


    }
  }
 
  //TODO FARE CONTROLLO NUMERI ERRORI E CAMPI
  public void testDeleteChoice() throws Throwable {
    Survey survey = this.createFakeSurveyForTest(true, true, false);
    String result = null;
    try {
      this.setUserOnSession("admin");
      // save the survey
      this.getSurveyManager().saveSurvey(survey);
      // update internal id's by reloading the object
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      // invoke without parameters
      this.initAction("/do/jpsurvey/Survey", "deleteChoice");
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.INPUT, result);
     
      // invoke with wrong parameters
      this.initAction("/do/jpsurvey/Survey", "deleteChoice");
      this.addParameter("choiceId", -1);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
     
      // invoke with correct parameters
      this.initAction("/do/jpsurvey/Survey", "deleteChoice");
      this.addParameter("choiceId", survey.getQuestions().get(0).getChoices().get(0).getId());
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
     
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      assertNotNull(survey);
      assertNotNull(survey.getQuestions());
      assertNotNull(survey.getQuestions().get(0).getChoices());
      assertEquals(1, survey.getQuestions().get(0).getChoices().size());
    } catch (Throwable t) {
      throw t;
    } finally {
      this.getSurveyManager().deleteSurvey(survey.getId());
    }
  }
View Full Code Here


    }
  }
 
  //TODO FARE CONTROLLO NUMERI ERRORI E CAMPI
  public void testMoveChoiceDown() throws Throwable {
    Survey survey = this.createFakeSurveyForTest(true, true, false);
    Survey test = null;
    String result = null;
    try {
      this.setUserOnSession("admin");
      // save the survey
      this.getSurveyManager().saveSurvey(survey);
      // update internal id's by reloading the object
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      // invoke without parameters
      this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.INPUT, result);
     
      // invoke with invalid id
      this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
      this.addParameter("choiceId", -1);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
     
      // move down the last has no effects
      test = this.getSurveyManager().loadSurvey(survey.getId());
      this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
      this.addParameter("choiceId", survey.getQuestions().get(0).getChoices().get(1).getId());
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      assertNotNull(survey);
      assertEquals(survey.getQuestions().get(0).getChoices().get(1).getId(), test.getQuestions().get(0).getChoices().get(1).getId());
     
      // normal operations
      test=getSurveyManager().loadSurvey(survey.getId());
      this.initAction("/do/jpsurvey/Survey", "moveChoiceDown");
      this.addParameter("choiceId", survey.getQuestions().get(0).getChoices().get(0).getId());
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      assertNotNull(survey);
      assertEquals(survey.getQuestions().get(0).getChoices().get(1).getId(), test.getQuestions().get(0).getChoices().get(0).getId());
    } catch (Throwable t) {
      throw t;
    } finally {
      getSurveyManager().deleteSurvey(survey.getId());
    }
View Full Code Here

    }
  }
 
  //TODO FARE CONTROLLO NUMERI ERRORI E CAMPI
  public void testMoveChoiceUp() throws Throwable {
    Survey survey = this.createFakeSurveyForTest(true, true, false);
    Survey test = null;
    String result = null;
    try {
      this.setUserOnSession("admin");
      // save the survey
      this.getSurveyManager().saveSurvey(survey);
      // update internal id's by reloading the object
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      // invoke without parameters
      this.initAction("/do/jpsurvey/Survey", "moveChoiceUp");
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.INPUT, result);
     
      // invoke with invalid id
      this.initAction("/do/jpsurvey/Survey", "moveChoiceUp");
      this.addParameter("choiceId", -1);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
     
      // move up the first
      test=getSurveyManager().loadSurvey(survey.getId());
      this.initAction("/do/jpsurvey/Survey", "moveChoiceUp");
      this.addParameter("choiceId", survey.getQuestions().get(0).getChoices().get(0).getId());
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      assertNotNull(survey);
      assertEquals(survey.getQuestions().get(0).getChoices().get(1).getId(), test.getQuestions().get(0).getChoices().get(1).getId());
     
      // normal operations
      test=getSurveyManager().loadSurvey(survey.getId());
      this.initAction("/do/jpsurvey/Survey", "moveChoiceUp");
      this.addParameter("choiceId", survey.getQuestions().get(0).getChoices().get(1).getId());
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      survey = this.getSurveyManager().loadSurvey(survey.getId());
      assertNotNull(survey);
      assertEquals(survey.getQuestions().get(0).getChoices().get(1).getId(), test.getQuestions().get(0).getChoices().get(0).getId());
    } catch (Throwable t) {
      throw t;
    } finally {
      this.getSurveyManager().deleteSurvey(survey.getId());
    }
View Full Code Here

    }
    return SUCCESS;
  }
 
  public String joinImage() {
    Survey survey = null;
    try {
      survey = this.getSurveyManager().loadSurvey(this.getSurveyId());
      if (null != survey) {
        survey.setImageId(this.getResourceId());
        this.getSurveyManager().updateSurvey(survey);
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "joinImage");
      return FAILURE;
View Full Code Here

  }
 
  public void testJoinImage() throws Throwable {
    String result = null;
    SurveyImageAction action = null;
    Survey backup = null;
    Survey survey = null;
    try {
      this.setUserOnSession("admin");
     
      // test on unknown non existent survey
      this.initAction("/do/jpsurvey/Survey", "joinImage");
      this.addParameter("resourceId", "IMG69");
      this.addParameter("surveyId", -1);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(Action.SUCCESS, result);
      action = (SurveyImageAction) this.getAction();     
      assertNotNull(action.getResources());
      assertFalse(action.getResources().isEmpty());
     
      // test on effective survey
      backup = this.getSurveyManager().loadSurvey(1);
      if (null != backup) {
        this.initAction("/do/jpsurvey/Survey", "joinImage");
        this.addParameter("resourceId", "IMG069");
        this.addParameter("surveyId", 1);
        result = this.executeAction();
        assertNotNull(result);
        assertEquals(Action.SUCCESS, result);
        action = (SurveyImageAction) this.getAction();     
        assertNotNull(action.getResources());
        assertFalse(action.getResources().isEmpty());
        survey = this.getSurveyManager().loadSurvey(1);
        assertEquals("IMG069", survey.getImageId());
      }     
    } catch (Throwable t) {
      throw t;
    } finally {
      // RIPRISTINA LO STATO DEL DB
View Full Code Here

public class SurveyDetailAction extends BaseAction implements ISurveyDetailAction {
 
  @Override
  public String view() {
    try {
      Survey survey = this.getSurvey();
      boolean isQuestionnarie = this.getQuestionnaire().booleanValue();
      if (survey == null || survey.isQuestionnaire() != isQuestionnarie) {
        String errorMsg = isQuestionnarie ? "Error.questionnairy.notFound" : "Error.poll.notFound";
        this.addActionError(this.getText(errorMsg));
        return "listSurveys";
      }
    } catch (Throwable t) {
View Full Code Here

    try {
      Question targetQuestion = this.getQuestionDAO().loadQuestion(id);
      if (null == targetQuestion) {
        return;
      }
      Survey survey = this.getSurveyDAO().loadSurvey(targetQuestion.getSurveyId());
      if (null == survey) {
        return;
      }
      List<Question> questions = survey.getQuestions();
      this.getQuestionDAO().swapQuestionPosition(targetQuestion, questions, isUp);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "swapChoicePosition");
      throw new ApsSystemException("Error while swapping two choices in a question", t);
    }
View Full Code Here

import com.agiletec.plugins.jpsurvey.aps.system.services.survey.model.SurveyRecord;

public class TestSurveyManager extends ApsPluginBaseTestCase {
 
  public void testLoadSurvey() throws Throwable {
    Survey survey = null;
    ApsProperties prop = null;
    try {
      survey = this.getSurveyManager().loadSurvey(0);
      assertNull(survey);
      survey = this.getSurveyManager().loadSurvey(1);
      assertNotNull(survey);
      assertEquals("ignored", survey.getGroupName());
      assertNotNull(survey.getDescriptions());
      assertTrue(survey.isActive());
      assertTrue(survey.isGatherUserInfo());
      assertTrue(survey.isPublicResult());
      assertFalse(survey.isPublicPartialResult());
      assertTrue(survey.isQuestionnaire());
      assertNotNull(survey.getTitles());
      assertFalse(survey.isRestricted());
      assertNotNull(survey.getQuestions());
      assertFalse(survey.getQuestions().isEmpty());
      assertEquals(2, survey.getQuestions().size());
      assertEquals("IMG001", survey.getImageId());
      prop = survey.getImageDescriptions();
      assertEquals("Barrali di notte", prop.getProperty("it"));
      // questions must belong to the same survey
      assertTrue(survey.getQuestions().get(0).getSurveyId() == survey.getId());
      assertTrue(survey.getQuestions().get(0).getSurveyId() == survey.getQuestions().get(1).getSurveyId());
      assertNotNull(survey.getQuestions().get(0).getChoices());
      // check choices size
      List<Choice> list = survey.getQuestions().get(0).getChoices();
      assertNotNull(list);
      assertEquals(4, list.size());
      assertTrue(list.get(3).isFreeText());
      assertEquals(4, list.get(3).getPos());
    } catch (Throwable t) {
View Full Code Here

      this.getSurveyManager().deleteChoice(choice.getId());
    }
  }
 
  public void testDeleteQuestion() throws Throwable {
    Survey survey = this.getFakeActiveSurvey();
    Survey actual = null;
    Question question = null;
    try {
      // delete an unknown question, no exceptions!
      question = this.getSurveyManager().loadQuestion(222);
      assertNull(question);
      this.getSurveyManager().deleteQuestion(222);
      // save a survey with a single question
      survey.getQuestions().remove(0);
      assertEquals(1, survey.getQuestions().size());
      this.getSurveyManager().saveSurvey(survey);
      this.getSurveyManager().deleteQuestion(survey.getQuestions().get(0).getId());
      actual = this.getSurveyManager().loadSurvey(survey.getId());
      assertNotNull(actual);
      assertNotNull(actual.getQuestions());
      assertTrue(actual.getQuestions().isEmpty());
    } catch (Throwable t) {
      throw t;
    } finally {
      this.getSurveyManager().deleteSurvey(survey.getId());
    }
View Full Code Here

      this.getSurveyManager().deleteSurvey(survey.getId());
    }
  }
 
  public void testDeleteSurvey() throws Throwable {
    Survey survey = null;
    try {
      // delete an unknown survey
      survey = this.getSurveyManager().loadSurvey(555);
      assertNull(survey);
      this.getSurveyManager().deleteSurvey(555);
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpsurvey.aps.system.services.survey.model.Survey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.