PlanService { public List<Plan> getPlansById(Integer id) { List<Plan> plans = planRepository.findPlansByUserId(id); return plans; } @Autowired  PlanService(PlanRepository myPlanRepository);  PlanService(); List<Plan> getPlansById(Integer id); Plan getPlansByPlaceId(Integer id); Plan addPlan(Plan plan); boolean deletePlan(int id); void setRepository(PlanRepository repository);  }
@Test public void testGetPlansById() { when(planRepository.findPlansByUserId(plan.getUserId())).thenReturn(plans); assertEquals(plans, planService.getPlansById(plan.getUserId())); }
@Test public void testInvalidGetPlansById() { when(planRepository.findPlansByUserId(plan.getUserId())).thenReturn(plans); when(planRepository.findPlansByUserId(plan2.getUserId())).thenReturn(plans); assertEquals(planService.getPlansById(plan.getUserId()), planService.getPlansById(plan.getUserId())); }