### Question:
TopicController { @RequestMapping(value = "/topics/move/json/{topicId}", method = RequestMethod.POST) @ResponseBody public JsonResponse moveTopic(@PathVariable(TOPIC_ID) Long topicId, @RequestParam(BRANCH_ID) Long branchId) throws NotFoundException { Topic topic = topicFetchService.get(topicId); topicModificationService.moveTopic(topic, branchId); return new JsonResponse(JsonResponseStatus.SUCCESS, converter.convertTopicToDto(topic).getTopicUrl()); } @Autowired  TopicController(TopicModificationService topicModificationService,
                           PostService postService,
                           BranchService branchService,
                           UserService userService,
                           BreadcrumbBuilder breadcrumbBuilder,
                           LocationService locationService,
                           SessionRegistry sessionRegistry,
                           TopicFetchService topicFetchService,
                           TopicDraftService topicDraftService,
                           EntityToDtoConverter converter,
                           RetryTemplate retryTemplate); @InitBinder void initBinder(WebDataBinder binder); @RequestMapping(value = "/topics/new", method = RequestMethod.GET) ModelAndView showNewTopicPage(@RequestParam(BRANCH_ID) Long branchId); @RequestMapping(value = "/topics/new", method = RequestMethod.POST) ModelAndView createTopic(@Valid @ModelAttribute final TopicDto topicDto,
                                    BindingResult result,
                                    @RequestParam(BRANCH_ID) Long branchId); @RequestMapping(value = "/topics/draft", method = RequestMethod.POST) @ResponseBody JsonResponse saveDraft(@Valid @RequestBody TopicDraft topicDraft,
                                  BindingResult result); @RequestMapping(value = "/topics/draft", method = RequestMethod.DELETE) @ResponseBody JsonResponse deleteDraft(); @RequestMapping(value = "/topics/{topicId}", method = RequestMethod.DELETE) ModelAndView deleteTopic(@PathVariable(TOPIC_ID) Long topicId); @RequestMapping(value = "/topics/{topicId}", method = RequestMethod.GET) ModelAndView showTopicPage(WebRequest request, @PathVariable(TOPIC_ID) Long topicId,
                                      @RequestParam(value = "page", defaultValue = "1", required = false) String page); @RequestMapping(value = "/topics/{topicId}/edit", method = RequestMethod.GET) ModelAndView editTopicPage(@PathVariable(TOPIC_ID) Long topicId); @RequestMapping(value = "/topics/{topicId}/edit", method = RequestMethod.POST) ModelAndView editTopic(@Valid @ModelAttribute TopicDto topicDto,
                                  BindingResult result,
                                  @PathVariable(TOPIC_ID) Long topicId); @RequestMapping(value = "/topics/move/json/{topicId}", method = RequestMethod.POST) @ResponseBody JsonResponse moveTopic(@PathVariable(TOPIC_ID) Long topicId,
                          @RequestParam(BRANCH_ID) Long branchId); @RequestMapping(value = "/topics/{topicId}/close") String closeTopic(@PathVariable(TOPIC_ID) Long topicId); @RequestMapping(value = "/topics/{topicId}/open") String openTopic(@PathVariable(TOPIC_ID) Long topicId); static final String TOPIC_ID; static final String BRANCH_ID; static final String BREADCRUMB_LIST; static final String POST_DTO; static final String POLL; }### Answer:
@Test public void moveTopic() throws NotFoundException { String url = "example.com"; Topic topic = createTopic(); TopicDto topicDto = new TopicDto(topic); topicDto.setTopicUrl(url); when(topicFetchService.get(TOPIC_ID)).thenReturn(topic); when(converter.convertTopicToDto(topic)).thenReturn(topicDto); JsonResponse response = controller.moveTopic(TOPIC_ID, BRANCH_ID); assertEquals(response.getStatus(), JsonResponseStatus.SUCCESS); assertEquals(response.getResult(), url); verify(topicModificationService).moveTopic(topic, BRANCH_ID); }
@Test(expectedExceptions = NotFoundException.class) public void moveTopicShouldThrowExceptionIfTopicNotFound() throws Exception { when(topicFetchService.get(anyLong())).thenThrow(new NotFoundException()); controller.moveTopic(1L, 1L); }