### Question:
TeamUserController { @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getAllUsers() { logger.debug("Fetching All Users "); List<TeamUser> userList = Lists.newArrayList(userDetailsService.findAll()); if (userList == null || userList.isEmpty()) { final String error = " No User Found in TeamUser repository"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(userList, HttpStatus.OK); }  @ApiOperation(value = "This API returns all TeamUser Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all TeamUser Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found") }) @RequestMapping(value = "/api/users/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getAllUsers(); @ApiOperation(value = "This API returns TeamUser Object present in Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned TeamUser Object for current user"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No TeamUser object found for current user") }) @RequestMapping(value = "/api/user/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getCurrentTeamOfUser(HttpServletRequest request); @ApiOperation(value = "This API updates TeamUser Objects into Elastic Search for current user", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "TeamUser objects successfully updated into ES for current user"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 404, message = "TeamUser object not found in ES for current user"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/user/{newteamname}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateTeamOfUser(HttpServletRequest request,
			@PathVariable("newteamname") String newteamname);  }### Answer:
@Test public void testGetAllUsers() { TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<TeamUser> teamUserList = new ArrayList<>(); teamUserList.add(teamUser); when(teamUserRepository.findAll()).thenReturn(teamUserList); @SuppressWarnings("unchecked") List<TeamUser> getAllUsers = (List<TeamUser>) teamUserController.getAllUsers().getBody(); assertEquals(1, getAllUsers.size()); assertEquals(USERNAME, getAllUsers.get(0).getUserName()); assertEquals(TEAMNAME, getAllUsers.get(0).getTeamName()); }
@Test public void testGetAllUsersErrCndtn() { List<TeamUser> teamUserList = new ArrayList<>(); when(teamUserRepository.findAll()).thenReturn(teamUserList); MessageWrapper apiError = (MessageWrapper) teamUserController.getAllUsers().getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals(" No User Found in TeamUser repository", apiError.getStatusMessage()); }