@Test public void listPlans() { this.plan.setName("Plan Name"); List<Plan> plans = new ArrayList<>(); plans.add(plan); Mockito.when(this.planRepository.findAll(Mockito.any(Example.class))).thenReturn(plans); List<Plan> planResp = this.planService.list(this.planDTO); assertEquals(plans.size(), planResp.size()); Mockito.verify(this.planRepository, Mockito.times(1)).findAll(Mockito.any(Example.class)); }
@Transactional(readOnly = true) public PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO) { Plan plan = GenericConverter.mapper(planDTO, Plan.class); Example<Plan> example = Example.of(plan, ExampleMatcher.matching().withIgnorePaths("defaultPlan", "api.cors").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Plan> page = planRepository.findAll(example, pageable); PlanPage planPage = new PlanPage(PageDTO.build(page)); return planPage; }
PlanService { @Transactional(readOnly = true) public PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO) { Plan plan = GenericConverter.mapper(planDTO, Plan.class); Example<Plan> example = Example.of(plan, ExampleMatcher.matching().withIgnorePaths("defaultPlan", "api.cors").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Plan> page = planRepository.findAll(example, pageable); PlanPage planPage = new PlanPage(PageDTO.build(page)); return planPage; } }
PlanService { @Transactional(readOnly = true) public PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO) { Plan plan = GenericConverter.mapper(planDTO, Plan.class); Example<Plan> example = Example.of(plan, ExampleMatcher.matching().withIgnorePaths("defaultPlan", "api.cors").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Plan> page = planRepository.findAll(example, pageable); PlanPage planPage = new PlanPage(PageDTO.build(page)); return planPage; }  }
PlanService { @Transactional(readOnly = true) public PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO) { Plan plan = GenericConverter.mapper(planDTO, Plan.class); Example<Plan> example = Example.of(plan, ExampleMatcher.matching().withIgnorePaths("defaultPlan", "api.cors").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Plan> page = planRepository.findAll(example, pageable); PlanPage planPage = new PlanPage(PageDTO.build(page)); return planPage; }  @Transactional(readOnly = true) Plan find(Long id); @Transactional(readOnly = true) PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO); @Transactional(readOnly = true) List<Plan> list(PlanDTO planDTO); Plan save(PlanDTO planDTO); Plan update(Long id, PlanDTO planDTO); void delete(Long id); }
PlanService { @Transactional(readOnly = true) public PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO) { Plan plan = GenericConverter.mapper(planDTO, Plan.class); Example<Plan> example = Example.of(plan, ExampleMatcher.matching().withIgnorePaths("defaultPlan", "api.cors").withIgnoreCase().withStringMatcher(StringMatcher.CONTAINING)); Pageable pageable = Pageable.setPageable(pageableDTO.getOffset(), pageableDTO.getLimit()); Page<Plan> page = planRepository.findAll(example, pageable); PlanPage planPage = new PlanPage(PageDTO.build(page)); return planPage; }  @Transactional(readOnly = true) Plan find(Long id); @Transactional(readOnly = true) PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO); @Transactional(readOnly = true) List<Plan> list(PlanDTO planDTO); Plan save(PlanDTO planDTO); Plan update(Long id, PlanDTO planDTO); void delete(Long id);  }