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 testDeleteSurvey() throws Throwable {
    Survey poll = this.prepareSurveyForTest(false,false);
    Survey questionnaire = this.prepareSurveyForTest(true,false);
    Survey testPoll = null;
    String result = null;
    try {
      this.setUserOnSession("admin");
      this.getSurveyManager().saveSurvey(poll);
      this.getSurveyManager().saveSurvey(questionnaire);
View Full Code Here


    }
  }
 
  //TODO FARE CONTROLLO NUMERI ERRORI E CAMPI
  public void testPublishSurvey() throws Throwable {
    Survey poll = this.prepareSurveyForTest(false, false);
    Survey questionnaire = this.prepareSurveyForTest(true, false);
    Survey actual = null;
    String result = null;
    try {
      this.setUserOnSession("admin");
      this.getSurveyManager().saveSurvey(poll);
      this.getSurveyManager().saveSurvey(questionnaire);
      // publish existing poll
      assertTrue(poll.isPublishable());
      this.initAction("/do/jpsurvey/Survey", "publishSurvey");
      assertEquals(3, poll.getId());
      assertFalse(poll.isActive());
      this.addParameter("surveyId", poll.getId());
      this.addParameter("questionnaire", false);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      actual = this.getSurveyManager().loadSurvey(poll.getId());
      assertNotNull(actual);
      assertTrue(actual.isActive());
      // publish existing questionnaire
      assertTrue(questionnaire.isPublishable());
      this.initAction("/do/jpsurvey/Survey", "publishSurvey");
      assertEquals(4, questionnaire.getId());
      assertFalse(questionnaire.isActive());
      this.addParameter("surveyId", questionnaire.getId());
      this.addParameter("questionnaire", true);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      actual = this.getSurveyManager().loadSurvey(questionnaire.getId());
      assertNotNull(actual);
      assertTrue(actual.isActive());
     
      // publish existing questionnaire
      this.initAction("/do/jpsurvey/Survey", "publishSurvey");
      assertFalse(questionnaire.isActive());
      this.addParameter("surveyId", questionnaire.getId());
      this.addParameter("questionnaire", true);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      actual = this.getSurveyManager().loadSurvey(questionnaire.getId());
      assertNotNull(actual);
      assertTrue(actual.isActive());
      questionnaire.setActive(false);
      questionnaire.getQuestions().get(1).getChoices().remove(0);
      questionnaire.getQuestions().get(1).getChoices().get(0).setFreeText(false);
      getSurveyManager().updateSurvey(questionnaire); // NOT PUBLISHABLE ANYMORE
      this.initAction("/do/jpsurvey/Survey", "publishSurvey");
      assertFalse(questionnaire.isActive());
      this.addParameter("surveyId", questionnaire.getId());
      this.addParameter("questionnaire", true);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      actual=this.getSurveyManager().loadSurvey(questionnaire.getId());
      assertNotNull(actual);
      assertFalse(actual.isActive());
      assertEquals(2, actual.getQuestions().size());
     
      // enable unknown survey
      this.initAction("/do/jpsurvey/Survey", "publishSurvey");
      assertEquals(4, questionnaire.getId());
      assertFalse(questionnaire.isActive());
View Full Code Here

    }
  }
 
  //TODO FARE CONTROLLO NUMERI ERRORI E CAMPI
  public void testRestireSurvey() throws Throwable {
    Survey poll = this.prepareSurveyForTest(false, true);
    Survey questionnaire = this.prepareSurveyForTest(true, true);
    Survey testSurvey = null;
    String result = null;
    try {
      this.setUserOnSession("admin");
      this.getSurveyManager().saveSurvey(poll);
      this.getSurveyManager().saveSurvey(questionnaire);
      assertTrue(questionnaire.isActive());
      assertTrue(poll.isActive());
      // invoke action without parameters
      this.initAction("/do/jpsurvey/Survey", "retireSurvey");
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.INPUT, result);
      // retire questionnaire
      this.initAction("/do/jpsurvey/Survey", "retireSurvey");
      this.addParameter("surveyId", questionnaire.getId());
      this.addParameter("questionnaire", true);
      result = this.executeAction();
      assertNotNull(result);
      assertEquals(BaseAction.SUCCESS, result);
      testSurvey=this.getSurveyManager().loadSurvey(questionnaire.getId());
      assertNotNull(testSurvey);
      assertFalse(testSurvey.isActive());
      // retire poll
      this.initAction("/do/jpsurvey/Survey", "retireSurvey");
      this.addParameter("surveyId", poll.getId());
      this.addParameter("questionnaire", false);
      result = this.executeAction();
      assertEquals(BaseAction.SUCCESS, result);
      testSurvey=this.getSurveyManager().loadSurvey(poll.getId());
      assertNotNull(testSurvey);
      assertFalse(testSurvey.isActive());
    } catch (Throwable t) {
      throw t;
    } finally {
      this.getSurveyManager().deleteSurvey(poll.getId());
      this.getSurveyManager().deleteSurvey(questionnaire.getId());
View Full Code Here

      this.getSurveyManager().deleteSurvey(questionnaire.getId());
    }
  }
 
  public void testAssociateSurveyImageEntry() throws Throwable {
    Survey survey = this.prepareSurveyForTest(true, false);
    Survey actual = null;
    SurveyAction action = null;
    String result = null;
    try {
      this.setUserOnSession("admin");
      this.getSurveyManager().saveSurvey(survey);
      assertNotNull(survey);
      // Test with invalid strutsAction
      this.initAction("/do/jpsurvey/Survey", "associateSurveyImageEntry");
      this.addParameter("surveyId", survey.getId());
      this.addParameter("questionnaire", true);
      this.addParameter("checkCookie", true);
      this.addParameter("description-it", "mucca");
      this.addParameter("title-it", "lilla");
      this.addParameter("imageDescription-it", "cioccolatosa");
      this.addParameter("resourceTypeCode", "Image");
      this.addParameter("groupName", Group.FREE_GROUP_NAME);
      this.addParameter("startDate", "10/06/2009");
      this.addParameter("strutsAction", ApsAdminSystemConstants.ADD);
      this.addParameter("profileUser", 0);
      this.addParameter("gatherUserInfo", survey.isGatherUserInfo());
      this.addParameter("imageId", 22);
      result = this.executeAction();
      action = (SurveyAction) this.getAction();
      assertNotNull(result);
      assertEquals(action.INPUT, result);
      assertEquals((Integer)survey.getId(), action.getSurveyId());
      // test with valid parameters
      this.initAction("/do/jpsurvey/Survey", "associateSurveyImageEntry");
      this.addParameter("surveyId", survey.getId());
//      this.addParameter("questionnaire", true);
      this.addParameter("checkCookie", false);
      this.addParameter("description-it", "mucca");
      this.addParameter("title-it", "lilla");
      this.addParameter("imageDescription-it", "cioccolatosa");
      this.addParameter("resourceTypeCode", "Image");
      this.addParameter("groupName", Group.FREE_GROUP_NAME);
      this.addParameter("startDate", "10/06/2009");
      this.addParameter("strutsAction", ApsAdminSystemConstants.EDIT);
      this.addParameter("profileUser", 0);
      this.addParameter("gatherUserInfo", survey.isGatherUserInfo());
      this.addParameter("imageId", 22);
      result = this.executeAction();
      action = (SurveyAction) this.getAction();
      assertNotNull(result);
      assertEquals(action.SUCCESS, result);
      assertNotNull(action.getSurveyId());
      actual = this.getSurveyManager().loadSurvey(survey.getId());
      assertEquals("cioccolatosa", actual.getImageDescriptions().get("it"));
    } catch (Throwable t) {
      throw t;
    } finally {
      this.getSurveyManager().deleteSurvey(survey.getId());
    }
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.