Skip to content

Instantly share code, notes, and snippets.

Created October 31, 2012 22:08
Constants in Unit Testing
@Controller
public class ShowUserController {
public static final String SUCCESS_VIEW = "showUser"; // Key Constant (moved here from the test class)
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showUser(@PathVariable long userId) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName(SUCCESS_VIEW);
modelAndView.setModel(buildModel(userId));
return modelAndView;
}
private UserValueObject buildModel(long userId) {
// creating the value object for presentation in here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment