Source:
protected void testExecute() throws Exception { InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); CourseAttributes typicalCourse1 = typicalBundle.courses.get("typicalCourse1"); FeedbackSessionAttributes sessionPublishedInCourse1 = typicalBundle.feedbackSessions.get("closedSession"); FeedbackSessionAttributes session1InCourse1 = typicalBundle.feedbackSessions.get("session1InCourse1"); loginAsInstructor(instructor1OfCourse1.getGoogleId()); ______TS("Not enough parameters"); verifyHttpParameterFailure(); verifyHttpParameterFailure(Const.ParamsNames.COURSE_ID, typicalCourse1.getId()); verifyHttpParameterFailure(Const.ParamsNames.FEEDBACK_SESSION_NAME, sessionPublishedInCourse1.getFeedbackSessionName()); ______TS("Typical success case"); assertTrue(sessionPublishedInCourse1.isPublished()); String[] params = new String[] { Const.ParamsNames.COURSE_ID, typicalCourse1.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, sessionPublishedInCourse1.getFeedbackSessionName(), }; UnpublishFeedbackSessionAction a = getAction(params); JsonResult r = getJsonResult(a); assertEquals(HttpStatus.SC_OK, r.getStatusCode()); assertFalse(logic.getFeedbackSession(sessionPublishedInCourse1.getFeedbackSessionName(), typicalCourse1.getId()).isPublished()); ______TS("Failed case, session is not published yet"); assertFalse(session1InCourse1.isPublished()); String[] failedParams = new String[] { Const.ParamsNames.COURSE_ID, typicalCourse1.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), }; a = getAction(failedParams); r = getJsonResult(a); MessageOutput out = (MessageOutput) r.getOutput(); assertEquals(out.getMessage(), "Error unpublishing feedback session: Session has already been unpublished."); assertEquals(HttpStatus.SC_BAD_REQUEST, r.getStatusCode()); }

Target:
protected void testExecute() throws Exception { InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); CourseAttributes typicalCourse1 = typicalBundle.courses.get("typicalCourse1"); FeedbackSessionAttributes sessionPublishedInCourse1 = typicalBundle.feedbackSessions.get("closedSession"); FeedbackSessionAttributes session1InCourse1 = typicalBundle.feedbackSessions.get("session1InCourse1"); loginAsInstructor(instructor1OfCourse1.getGoogleId()); ______TS("Not enough parameters"); verifyHttpParameterFailure(); verifyHttpParameterFailure(Const.ParamsNames.COURSE_ID, typicalCourse1.getId()); verifyHttpParameterFailure(Const.ParamsNames.FEEDBACK_SESSION_NAME, sessionPublishedInCourse1.getFeedbackSessionName()); ______TS("Typical success case"); assertTrue(sessionPublishedInCourse1.isPublished()); String[] params = new String[] { Const.ParamsNames.COURSE_ID, typicalCourse1.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, sessionPublishedInCourse1.getFeedbackSessionName(), }; UnpublishFeedbackSessionAction a = getAction(params); JsonResult r = getJsonResult(a); assertEquals(HttpStatus.SC_OK, r.getStatusCode()); assertFalse(logic.getFeedbackSession(sessionPublishedInCourse1.getFeedbackSessionName(), typicalCourse1.getId()).isPublished()); assertEquals(1, a.getTaskQueuer().getTasksAdded().size()); ______TS("Failed case, session is not published yet"); assertFalse(session1InCourse1.isPublished()); String[] failedParams = new String[] { Const.ParamsNames.COURSE_ID, typicalCourse1.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session1InCourse1.getFeedbackSessionName(), }; a = getAction(failedParams); r = getJsonResult(a); MessageOutput out = (MessageOutput) r.getOutput(); assertEquals(out.getMessage(), "Error unpublishing feedback session: Session has already been unpublished."); assertEquals(HttpStatus.SC_BAD_REQUEST, r.getStatusCode()); }