@Test public void findCommonCourts_correct_order() { CommonCourt commonCourtOne = new CommonCourt(); commonCourtOne.setCode("0510"); commonCourtOne.setName("Sąd w Aninie"); CommonCourt commonCourtTwo = new CommonCourt(); commonCourtTwo.setCode("0520"); commonCourtTwo.setName("Sąd w Łodzi"); CommonCourt commonCourtThree = new CommonCourt(); commonCourtThree.setCode("0530"); commonCourtThree.setName("Sąd w Ryczywołach"); SimpleCommonCourt simpleCommonCourtOne = new SimpleCommonCourt(); simpleCommonCourtOne.setName("Sąd w Aninie"); SimpleCommonCourt simpleCommonCourtTwo = new SimpleCommonCourt(); simpleCommonCourtTwo.setName("Sąd w Łodzi"); SimpleCommonCourt simpleCommonCourtThree = new SimpleCommonCourt(); simpleCommonCourtThree.setName("Sąd w Ryczywołach"); List<CommonCourt> courtsWrongOrder = Arrays.asList(commonCourtThree, commonCourtOne, commonCourtTwo); List<CommonCourt> courtsRightOrder = Arrays.asList(commonCourtOne, commonCourtTwo, commonCourtThree); when(commonCourtRepository.findAll()).thenReturn(courtsWrongOrder); when(simpleCommonCourtConverter.convertCommonCourts(courtsRightOrder)) .thenReturn(Arrays.asList(simpleCommonCourtOne, simpleCommonCourtTwo, simpleCommonCourtThree)); List<SimpleCommonCourt> courts = ccListService.findCommonCourts(); assertEquals(3, courts.size()); assertEquals(courts.get(0).getName(), commonCourtOne.getName()); assertEquals(courts.get(1).getName(), commonCourtTwo.getName()); assertEquals(courts.get(2).getName(), commonCourtThree.getName()); }
@Cacheable(DICTIONARIES) public List<SimpleCommonCourt> findCommonCourts() { List<CommonCourt> commonCourts = commonCourtRepository.findAll(); Collections.sort(commonCourts, new CommonCourtComparator()); return simpleCommonCourtConverter.convertCommonCourts(commonCourts); }
CcListService { @Cacheable(DICTIONARIES) public List<SimpleCommonCourt> findCommonCourts() { List<CommonCourt> commonCourts = commonCourtRepository.findAll(); Collections.sort(commonCourts, new CommonCourtComparator()); return simpleCommonCourtConverter.convertCommonCourts(commonCourts); } }
CcListService { @Cacheable(DICTIONARIES) public List<SimpleCommonCourt> findCommonCourts() { List<CommonCourt> commonCourts = commonCourtRepository.findAll(); Collections.sort(commonCourts, new CommonCourtComparator()); return simpleCommonCourtConverter.convertCommonCourts(commonCourts); }  }
CcListService { @Cacheable(DICTIONARIES) public List<SimpleCommonCourt> findCommonCourts() { List<CommonCourt> commonCourts = commonCourtRepository.findAll(); Collections.sort(commonCourts, new CommonCourtComparator()); return simpleCommonCourtConverter.convertCommonCourts(commonCourts); }  @Cacheable(DICTIONARIES) List<SimpleCommonCourt> findCommonCourts(); @Cacheable(DICTIONARIES) List<SimpleEntity> findCcDivisions(long courtId); @Autowired void setCommonCourtRepository(CommonCourtRepository ccRepository); @Autowired void setCcDivisionRepository(CcDivisionRepository ccDivisionRepository); @Autowired void setSimpleEntityConverter(SimpleEntityConverter simpleEntityConverter); @Autowired void setSimpleCommonCourtConverter(SimpleCommonCourtConverter simpleCommonCourtConverter); }
CcListService { @Cacheable(DICTIONARIES) public List<SimpleCommonCourt> findCommonCourts() { List<CommonCourt> commonCourts = commonCourtRepository.findAll(); Collections.sort(commonCourts, new CommonCourtComparator()); return simpleCommonCourtConverter.convertCommonCourts(commonCourts); }  @Cacheable(DICTIONARIES) List<SimpleCommonCourt> findCommonCourts(); @Cacheable(DICTIONARIES) List<SimpleEntity> findCcDivisions(long courtId); @Autowired void setCommonCourtRepository(CommonCourtRepository ccRepository); @Autowired void setCcDivisionRepository(CcDivisionRepository ccDivisionRepository); @Autowired void setSimpleEntityConverter(SimpleEntityConverter simpleEntityConverter); @Autowired void setSimpleCommonCourtConverter(SimpleCommonCourtConverter simpleCommonCourtConverter);  }