Source:
public void testExecute() throws Exception { InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); String instructorId = instructor1OfCourse1.googleId; String courseId = instructor1OfCourse1.courseId; CourseCreateRequest courseCreateRequest = new CourseCreateRequest(); courseCreateRequest.setCourseName("New Course"); courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId("new-course"); ______TS("Typical case with new course id"); if (logic.isCoursePresent("new-course")) { CoursesLogic.inst().deleteCourseCascade("new-course"); } loginAsInstructor(instructorId); CreateCourseAction action = getAction(courseCreateRequest); JsonResult result = getJsonResult(action); assertEquals(HttpStatus.SC_OK, result.getStatusCode()); ______TS("Typical case with existing course id"); courseCreateRequest.setCourseName("Existing Course"); courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId(courseId); action = getAction(courseCreateRequest); result = getJsonResult(action); MessageOutput message = (MessageOutput) result.getOutput(); assertEquals(HttpStatus.SC_CONFLICT, result.getStatusCode()); assertEquals("Trying to create a Course that exists: " + courseId, message.getMessage()); ______TS("Typical case missing course id"); courseCreateRequest.setCourseName("New Course"); courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId(""); action = getAction(courseCreateRequest); result = getJsonResult(action); assertEquals(HttpStatus.SC_BAD_REQUEST, result.getStatusCode()); }

Target:
public void testExecute() throws Exception { ______TS("Not enough parameters"); verifyHttpParameterFailure(); ______TS("Typical case with new course id"); InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); String instructorId = instructor1OfCourse1.googleId; String courseId = instructor1OfCourse1.courseId; CourseCreateRequest courseCreateRequest = new CourseCreateRequest(); courseCreateRequest.setCourseName("New Course"); courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId("new-course"); if (logic.isCoursePresent("new-course")) { CoursesLogic.inst().deleteCourseCascade("new-course"); } loginAsInstructor(instructorId); CreateCourseAction action = getAction(courseCreateRequest); JsonResult result = getJsonResult(action); CourseData courseData = (CourseData) result.getOutput(); assertEquals(courseData.getCourseId(), "new-course"); assertEquals(courseData.getCourseName(), "New Course"); assertEquals(courseData.getTimeZone(), "UTC"); assertEquals(HttpStatus.SC_OK, result.getStatusCode()); assertTrue(logic.isCoursePresent("new-course")); ______TS("Typical case with existing course id"); courseCreateRequest.setCourseName("Existing Course"); courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId(courseId); action = getAction(courseCreateRequest); result = getJsonResult(action); MessageOutput message = (MessageOutput) result.getOutput(); assertEquals(HttpStatus.SC_CONFLICT, result.getStatusCode()); assertEquals("Trying to create a Course that exists: " + courseId, message.getMessage()); ______TS("Typical case missing course id"); courseCreateRequest.setCourseName("New Course"); courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId(""); action = getAction(courseCreateRequest); result = getJsonResult(action); assertEquals(HttpStatus.SC_BAD_REQUEST, result.getStatusCode()); }