PlanController { @RequestMapping(value = "/savePlan", method = RequestMethod.POST) public Plan AddPlans(@Validated(Create.class) @RequestBody Plan plan) { if (null != plan.getDateTravel()) { plan.setDateTravel(new java.sql.Date(plan.getDateTravel().getTime())); } else { plan.setDateTravel(new java.sql.Date(new Date().getTime())); } plan.setDateAdded(new java.sql.Date(new Date().getTime())); return planService.addPlan(plan); } @Autowired  PlanController(PlanService planService);  PlanController(); void setPlanService(PlanService planService); @RequestMapping(value = "/savePlan", method = RequestMethod.POST) Plan AddPlans(@Validated(Create.class) @RequestBody Plan plan); @RequestMapping(value = "/plan", method = RequestMethod.POST) List<Plan> GetPlans(@Validated(Create.class) @RequestBody Plan plan); @RequestMapping(value = "/deletePlace/{id}", method = RequestMethod.POST) boolean deletePlan(@PathVariable int id, @Validated(Create.class) @RequestBody Plan plan);  }
@Test public void testAddPlans() { when(planService.addPlan(plan)).thenReturn(plan); assertEquals(plan, planController.AddPlans(plan)); }
@Test public void testInvalidAddPlans() { assertEquals(null, planController.AddPlans(plan2)); }