Search in sources :

Example 11 with NullPostParameterException

use of teammates.common.exception.NullPostParameterException in project teammates by TEAMMATES.

the class InstructorCourseInstructorEditSaveActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructorToEdit = typicalBundle.instructors.get("instructor1OfCourse1");
    String instructorId = instructorToEdit.googleId;
    String courseId = instructorToEdit.courseId;
    String adminUserId = "admin.user";
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("Typical case: edit instructor successfully");
    String newInstructorName = "newName";
    String newInstructorEmail = "newEmail@email.com";
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.INSTRUCTOR_ID, instructorId, Const.ParamsNames.INSTRUCTOR_NAME, newInstructorName, Const.ParamsNames.INSTRUCTOR_EMAIL, newInstructorEmail, Const.ParamsNames.INSTRUCTOR_ROLE_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_DISPLAY_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER };
    InstructorCourseInstructorEditSaveAction saveAction = getAction(submissionParams);
    RedirectResult redirectResult = getRedirectResult(saveAction);
    AssertHelper.assertContains(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE, redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    assertEquals(String.format(Const.StatusMessages.COURSE_INSTRUCTOR_EDITED, newInstructorName), redirectResult.getStatusMessage());
    InstructorAttributes editedInstructor = instructorsLogic.getInstructorForGoogleId(courseId, instructorId);
    assertEquals(newInstructorName, editedInstructor.name);
    assertEquals(newInstructorEmail, editedInstructor.email);
    assertTrue(editedInstructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertTrue(editedInstructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertTrue(editedInstructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertTrue(editedInstructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    String expectedLogSegment = "Instructor <span class=\"bold\"> " + newInstructorName + "</span>" + " for Course <span class=\"bold\">[" + courseId + "]</span> edited.<br>" + "New Name: " + newInstructorName + "<br>New Email: " + newInstructorEmail;
    AssertHelper.assertContains(expectedLogSegment, saveAction.getLogMessage());
    ______TS("Failure case: edit failed due to invalid parameters");
    String invalidEmail = "wrongEmail.com";
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.INSTRUCTOR_ID, instructorId, Const.ParamsNames.INSTRUCTOR_NAME, instructorToEdit.name, Const.ParamsNames.INSTRUCTOR_EMAIL, invalidEmail, Const.ParamsNames.INSTRUCTOR_ROLE_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_DISPLAY_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, "true" };
    saveAction = getAction(submissionParams);
    redirectResult = getRedirectResult(saveAction);
    AssertHelper.assertContains(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE, redirectResult.getDestinationWithParams());
    assertTrue(redirectResult.isError);
    String expectedErrorMessage = new FieldValidator().getInvalidityInfoForEmail(invalidEmail);
    assertEquals(expectedErrorMessage, redirectResult.getStatusMessage());
    AssertHelper.assertContains(expectedErrorMessage, saveAction.getLogMessage());
    ______TS("Masquerade mode: edit instructor successfully");
    gaeSimulation.loginAsAdmin(adminUserId);
    newInstructorName = "newName2";
    newInstructorEmail = "newEmail2@email.com";
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.INSTRUCTOR_ID, instructorId, Const.ParamsNames.INSTRUCTOR_NAME, newInstructorName, Const.ParamsNames.INSTRUCTOR_EMAIL, newInstructorEmail, Const.ParamsNames.INSTRUCTOR_ROLE_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_DISPLAY_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, "true" };
    saveAction = getAction(addUserIdToParams(instructorId, submissionParams));
    redirectResult = getRedirectResult(saveAction);
    AssertHelper.assertContains(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE, redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    assertEquals(String.format(Const.StatusMessages.COURSE_INSTRUCTOR_EDITED, newInstructorName), redirectResult.getStatusMessage());
    editedInstructor = instructorsLogic.getInstructorForGoogleId(courseId, instructorId);
    assertEquals(newInstructorEmail, editedInstructor.email);
    assertEquals(newInstructorName, editedInstructor.name);
    expectedLogSegment = "Instructor <span class=\"bold\"> " + newInstructorName + "</span>" + " for Course <span class=\"bold\">[" + courseId + "]</span> edited.<br>" + "New Name: " + newInstructorName + "<br>New Email: " + newInstructorEmail;
    AssertHelper.assertContains(expectedLogSegment, saveAction.getLogMessage());
    // remove the new instructor entity that was created
    CoursesLogic.inst().deleteCourseCascade("icieat.courseId");
    ______TS("Unsuccessful case: test null course id parameter");
    submissionParams = new String[] { Const.ParamsNames.INSTRUCTOR_ID, instructorId, Const.ParamsNames.INSTRUCTOR_NAME, newInstructorName, Const.ParamsNames.INSTRUCTOR_EMAIL, newInstructorEmail, Const.ParamsNames.INSTRUCTOR_ROLE_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_DISPLAY_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, "true" };
    try {
        saveAction = getAction(submissionParams);
        getRedirectResult(saveAction);
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), e.getMessage());
    }
    ______TS("Unsuccessful case: test null instructor name parameter");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.INSTRUCTOR_ID, instructorId, Const.ParamsNames.INSTRUCTOR_EMAIL, newInstructorEmail, Const.ParamsNames.INSTRUCTOR_ROLE_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_DISPLAY_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, "true" };
    try {
        saveAction = getAction(submissionParams);
        getRedirectResult(saveAction);
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.INSTRUCTOR_NAME), e.getMessage());
    }
    ______TS("Unsuccessful case: test null instructor email parameter");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, courseId, Const.ParamsNames.INSTRUCTOR_ID, instructorId, Const.ParamsNames.INSTRUCTOR_NAME, newInstructorName, Const.ParamsNames.INSTRUCTOR_ROLE_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_DISPLAY_NAME, Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, "true", Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, "true" };
    try {
        saveAction = getAction(submissionParams);
        getRedirectResult(saveAction);
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.INSTRUCTOR_EMAIL), e.getMessage());
    }
}
Also used : NullPostParameterException(teammates.common.exception.NullPostParameterException) RedirectResult(teammates.ui.controller.RedirectResult) FieldValidator(teammates.common.util.FieldValidator) InstructorCourseInstructorEditSaveAction(teammates.ui.controller.InstructorCourseInstructorEditSaveAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 12 with NullPostParameterException

use of teammates.common.exception.NullPostParameterException in project teammates by TEAMMATES.

the class InstructorFeedbackResultsDownloadActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    gaeSimulation.loginAsInstructor(typicalBundle.instructors.get("instructor1OfCourse1").googleId);
    FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] paramsNormal = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
    String[] paramsNormalWithinSection = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.SECTION_NAME, "Section 1" };
    String[] paramsWithNullCourseId = { Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
    String[] paramsWithNullFeedbackSessionName = { Const.ParamsNames.COURSE_ID, session.getCourseId() };
    String[] paramsWithMissingResponsesShown = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_INDICATE_MISSING_RESPONSES, "true" };
    String[] paramsWithMissingResponsesHidden = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_INDICATE_MISSING_RESPONSES, "false" };
    ______TS("Typical case: results downloadable");
    InstructorFeedbackResultsDownloadAction action = getAction(paramsNormal);
    FileDownloadResult result = getFileDownloadResult(action);
    String expectedDestination = getPageResultDestination("filedownload", false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertFalse(result.isError);
    assertEquals("", result.getStatusMessage());
    String expectedFileName = session.getCourseId() + "_" + session.getFeedbackSessionName();
    assertEquals(expectedFileName, result.getFileName());
    verifyFileContentForSession1InCourse1(result.getFileContent(), session);
    ______TS("Typical successful case: student last name displayed properly after being specified with braces");
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    student1InCourse1.name = "new name {new last name}";
    StudentsLogic studentsLogic = StudentsLogic.inst();
    studentsLogic.updateStudentCascade(student1InCourse1.email, student1InCourse1);
    action = getAction(paramsNormal);
    result = getFileDownloadResult(action);
    expectedDestination = getPageResultDestination("filedownload", false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertFalse(result.isError);
    assertEquals("", result.getStatusMessage());
    expectedFileName = session.getCourseId() + "_" + session.getFeedbackSessionName();
    assertEquals(expectedFileName, result.getFileName());
    verifyFileContentForSession1InCourse1WithNewLastName(result.getFileContent(), session);
    removeAndRestoreTypicalDataBundle();
    ______TS("Typical case: results within section downloadable");
    action = getAction(paramsNormalWithinSection);
    result = getFileDownloadResult(action);
    expectedDestination = getPageResultDestination("filedownload", false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertFalse(result.isError);
    expectedFileName = session.getCourseId() + "_" + session.getFeedbackSessionName() + "_Section 1";
    assertEquals(expectedFileName, result.getFileName());
    verifyFileContentForSession1InCourse1WithinSection1(result.getFileContent(), session);
    ______TS("Failure case: params with null course id");
    try {
        action = getAction(paramsWithNullCourseId);
        result = getFileDownloadResult(action);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), e.getMessage());
    }
    ______TS("Failure case: params with null feedback session name");
    try {
        action = getAction(paramsWithNullFeedbackSessionName);
        result = getFileDownloadResult(action);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.FEEDBACK_SESSION_NAME), e.getMessage());
    }
    ______TS("Typical case: results with missing responses shown");
    action = getAction(paramsWithMissingResponsesShown);
    result = getFileDownloadResult(action);
    expectedDestination = getPageResultDestination("filedownload", false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertFalse(result.isError);
    expectedFileName = session.getCourseId() + "_" + session.getFeedbackSessionName();
    assertEquals(expectedFileName, result.getFileName());
    verifyFileContentForDownloadWithMissingResponsesShown(result.getFileContent(), session);
    ______TS("Typical case: results with missing responses hidden");
    action = getAction(paramsWithMissingResponsesHidden);
    result = getFileDownloadResult(action);
    expectedDestination = getPageResultDestination("filedownload", false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertFalse(result.isError);
    expectedFileName = session.getCourseId() + "_" + session.getFeedbackSessionName();
    assertEquals(expectedFileName, result.getFileName());
    verifyFileContentForDownloadWithMissingResponsesHidden(result.getFileContent(), session);
    ______TS("Typical case: results downloadable by question");
    final int questionNum2 = typicalBundle.feedbackQuestions.get("qn2InSession1InCourse1").getQuestionNumber();
    final String question2Id = fqLogic.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), questionNum2).getId();
    String[] paramsQuestion2 = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "2", Const.ParamsNames.FEEDBACK_QUESTION_ID, question2Id };
    action = getAction(paramsQuestion2);
    result = getFileDownloadResult(action);
    expectedDestination = getPageResultDestination("filedownload", false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertFalse(result.isError);
    assertEquals("", result.getStatusMessage());
    expectedFileName = session.getCourseId() + "_" + session.getFeedbackSessionName() + "_question2";
    assertEquals(expectedFileName, result.getFileName());
    verifyFileContentForQuestion2Session1InCourse1(result.getFileContent(), session);
    ______TS("Typical case: results within section downloadable by question");
    final int questionNum1 = typicalBundle.feedbackQuestions.get("qn1InSession1InCourse1").getQuestionNumber();
    final String question1Id = fqLogic.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), questionNum1).getId();
    String[] paramsQuestion1WithinSection = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.SECTION_NAME, "Section 1", Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_ID, question1Id };
    action = getAction(paramsQuestion1WithinSection);
    result = getFileDownloadResult(action);
    expectedDestination = getPageResultDestination("filedownload", false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertFalse(result.isError);
    expectedFileName = session.getCourseId() + "_" + session.getFeedbackSessionName() + "_Section 1" + "_question1";
    assertEquals(expectedFileName, result.getFileName());
    verifyFileContentForQuestion1Session1InCourse1WithinSection1(result.getFileContent(), session);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackResultsDownloadAction(teammates.ui.controller.InstructorFeedbackResultsDownloadAction) StudentsLogic(teammates.logic.core.StudentsLogic) NullPostParameterException(teammates.common.exception.NullPostParameterException) FileDownloadResult(teammates.ui.controller.FileDownloadResult) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 13 with NullPostParameterException

use of teammates.common.exception.NullPostParameterException in project teammates by TEAMMATES.

the class InstructorFeedbackUnpublishActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    gaeSimulation.loginAsInstructor(typicalBundle.instructors.get("instructor1OfCourse1").googleId);
    FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session2InCourse1");
    String[] paramsNormal = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
    String[] paramsWithNullCourseId = { Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
    String[] paramsWithNullFeedbackSessionName = { Const.ParamsNames.COURSE_ID, session.getCourseId() };
    ______TS("Typical successful case: session unpublishable");
    makeFeedbackSessionPublished(session);
    InstructorFeedbackUnpublishAction unpublishAction = getAction(paramsNormal);
    RedirectResult result = getRedirectResult(unpublishAction);
    String expectedDestination = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE, false, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_UNPUBLISHED, result.getStatusMessage());
    assertFalse(result.isError);
    verifySpecifiedTasksAdded(unpublishAction, Const.TaskQueue.FEEDBACK_SESSION_UNPUBLISHED_EMAIL_QUEUE_NAME, 1);
    TaskWrapper taskAdded = unpublishAction.getTaskQueuer().getTasksAdded().get(0);
    Map<String, String[]> paramMap = taskAdded.getParamMap();
    assertEquals(session.getCourseId(), paramMap.get(ParamsNames.EMAIL_COURSE)[0]);
    assertEquals(session.getSessionName(), paramMap.get(ParamsNames.EMAIL_FEEDBACK)[0]);
    ______TS("Unsuccessful case 1: params with null course id");
    String errorMessage = "";
    unpublishAction = getAction(paramsWithNullCourseId);
    try {
        unpublishAction.executeAndPostProcess();
        signalFailureToDetectException("NullPostParameterException expected");
    } catch (NullPostParameterException e) {
        errorMessage = e.getMessage();
    }
    assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), errorMessage);
    ______TS("Unsuccessful case 2: params with null feedback session name");
    errorMessage = "";
    unpublishAction = getAction(paramsWithNullFeedbackSessionName);
    try {
        unpublishAction.executeAndPostProcess();
        signalFailureToDetectException("NullPostParameterException expected");
    } catch (NullPostParameterException e) {
        errorMessage = e.getMessage();
    }
    assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.FEEDBACK_SESSION_NAME), errorMessage);
    ______TS("Unsuccessful case 3: trying to unpublish a session not currently published");
    makeFeedbackSessionUnpublished(session);
    unpublishAction = getAction(paramsNormal);
    result = getRedirectResult(unpublishAction);
    expectedDestination = getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE, true, "idOfInstructor1OfCourse1");
    assertEquals(expectedDestination, result.getDestinationWithParams());
    assertEquals("Error unpublishing feedback session: Session has already been unpublished.", result.getStatusMessage());
    assertTrue(result.isError);
    verifyNoTasksAdded(unpublishAction);
    makeFeedbackSessionPublished(session);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) TaskWrapper(teammates.common.util.TaskWrapper) NullPostParameterException(teammates.common.exception.NullPostParameterException) RedirectResult(teammates.ui.controller.RedirectResult) InstructorFeedbackUnpublishAction(teammates.ui.controller.InstructorFeedbackUnpublishAction) Test(org.testng.annotations.Test)

Example 14 with NullPostParameterException

use of teammates.common.exception.NullPostParameterException in project teammates by TEAMMATES.

the class AdminExceptionTestAction method execute.

@Override
// deliberately done for testing
@SuppressWarnings("PMD.AvoidThrowingNullPointerException")
protected ActionResult execute() throws EntityDoesNotExistException {
    gateKeeper.verifyAdminPrivileges(account);
    String error = getRequestParamValue(Const.ParamsNames.ERROR);
    if (error.equals(AssertionError.class.getSimpleName())) {
        throw new AssertionError("AssertionError Testing");
    } else if (error.equals(EntityDoesNotExistException.class.getSimpleName())) {
        throw new EntityDoesNotExistException("EntityDoesNotExistException Testing");
    } else if (error.equals(UnauthorizedAccessException.class.getSimpleName())) {
        throw new UnauthorizedAccessException();
    } else if (error.equals(NullPointerException.class.getSimpleName())) {
        throw new NullPointerException();
    } else if (error.equals(DeadlineExceededException.class.getSimpleName())) {
        throw new DeadlineExceededException();
    } else if (error.equals(NullPostParameterException.class.getSimpleName())) {
        throw new NullPostParameterException("test null post param exception");
    }
    statusToAdmin = "adminExceptionTest";
    return createRedirectResult(Const.ActionURIs.ADMIN_HOME_PAGE);
}
Also used : NullPostParameterException(teammates.common.exception.NullPostParameterException) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) DeadlineExceededException(com.google.apphosting.api.DeadlineExceededException) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

NullPostParameterException (teammates.common.exception.NullPostParameterException)14 Test (org.testng.annotations.Test)11 RedirectResult (teammates.ui.controller.RedirectResult)10 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)7 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)6 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)5 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)4 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)4 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)4 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)4 ShowPageResult (teammates.ui.controller.ShowPageResult)4 EmailWrapper (teammates.common.util.EmailWrapper)3 DataBundle (teammates.common.datatransfer.DataBundle)2 FeedbackNumericalScaleQuestionDetails (teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails)2 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)2 TaskWrapper (teammates.common.util.TaskWrapper)2 FeedbackSessionsDb (teammates.storage.api.FeedbackSessionsDb)2 DeadlineExceededException (com.google.apphosting.api.DeadlineExceededException)1 ArrayList (java.util.ArrayList)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1