ApiService { @Transactional(readOnly = true) public List<Plan> plansByApi(Long id) { Api found = apiRepository.findOne(id); HeimdallException.checkThrow(Objects.isNull(found), API_NOT_EXIST); Hibernate.initialize(found.getPlans()); return found.getPlans(); }  Api find(Long id); Swagger findSwaggerByApi(Long id); ApiPage list(ApiDTO apiDTO, PageableDTO pageableDTO); List<Api> list(ApiDTO apiDTO); Api save(ApiDTO apiDTO); Api update(Long id, ApiDTO apiDTO); Api updateBySwagger(Long id, String swagger, boolean override); void delete(Long id); @Transactional(readOnly = true) List<Plan> plansByApi(Long id);  }
@Test public void plansByApiTest() { List<Plan> plans = new ArrayList<>(); plans.add(new Plan()); plans.add(new Plan()); api.setPlans(plans); Mockito.when(apiRepository.findOne(Mockito.anyLong())).thenReturn(api); List<Plan> plansResp = apiService.plansByApi(1L); assertNotNull(plansResp); }