@Test public void findScChamberDivisions_correct_order() { SupremeCourtChamberDivision sccDivisionOne = new SupremeCourtChamberDivision(); sccDivisionOne.setName("Wydział Odwoławczo-Kasacyjny"); SupremeCourtChamberDivision sccDivisionTwo = new SupremeCourtChamberDivision(); sccDivisionTwo.setName("Wydział IV"); SupremeCourtChamberDivision sccDivisionThree = new SupremeCourtChamberDivision(); sccDivisionThree.setName("Wydział IX"); SimpleEntity simpleSccDivisionOne = new SimpleEntity(); simpleSccDivisionOne.setName("Wydział Odwoławczo-Kasacyjny"); SimpleEntity simpleSccDivisionTwo = new SimpleEntity(); simpleSccDivisionTwo.setName("Wydział IV"); SimpleEntity simpleSccDivisionThree = new SimpleEntity(); simpleSccDivisionThree.setName("Wydział IX"); List<SupremeCourtChamberDivision> divisionsWrongOrder = Arrays.asList(sccDivisionTwo, sccDivisionThree, sccDivisionOne); List<SupremeCourtChamberDivision> divisionsRightOrder = Arrays.asList(sccDivisionOne, sccDivisionTwo, sccDivisionThree); when(scChamberDivisionRepository.findAllByScChamberId(1)).thenReturn(divisionsWrongOrder); when(simpleEntityConverter.convertScChamberDivisions(divisionsRightOrder)) .thenReturn(Arrays.asList(simpleSccDivisionOne, simpleSccDivisionTwo, simpleSccDivisionThree)); List<SimpleEntity> chamberDivisions = scListService.findScChamberDivisions(1); assertEquals(3, chamberDivisions.size()); assertEquals(chamberDivisions.get(0).getName(), sccDivisionOne.getName()); assertEquals(chamberDivisions.get(1).getName(), sccDivisionTwo.getName()); assertEquals(chamberDivisions.get(2).getName(), sccDivisionThree.getName()); }
@Cacheable(DICTIONARIES) public List<SimpleEntity> findScChamberDivisions(long chamberId) { List<SupremeCourtChamberDivision> chamberDivisions = scChamberDivisionRepository.findAllByScChamberId(chamberId); Collections.sort(chamberDivisions, new ScChamberDivisionComparator()); return simpleEntityConverter.convertScChamberDivisions(chamberDivisions); }
ScListService { @Cacheable(DICTIONARIES) public List<SimpleEntity> findScChamberDivisions(long chamberId) { List<SupremeCourtChamberDivision> chamberDivisions = scChamberDivisionRepository.findAllByScChamberId(chamberId); Collections.sort(chamberDivisions, new ScChamberDivisionComparator()); return simpleEntityConverter.convertScChamberDivisions(chamberDivisions); } }
ScListService { @Cacheable(DICTIONARIES) public List<SimpleEntity> findScChamberDivisions(long chamberId) { List<SupremeCourtChamberDivision> chamberDivisions = scChamberDivisionRepository.findAllByScChamberId(chamberId); Collections.sort(chamberDivisions, new ScChamberDivisionComparator()); return simpleEntityConverter.convertScChamberDivisions(chamberDivisions); }  }
ScListService { @Cacheable(DICTIONARIES) public List<SimpleEntity> findScChamberDivisions(long chamberId) { List<SupremeCourtChamberDivision> chamberDivisions = scChamberDivisionRepository.findAllByScChamberId(chamberId); Collections.sort(chamberDivisions, new ScChamberDivisionComparator()); return simpleEntityConverter.convertScChamberDivisions(chamberDivisions); }  @Cacheable(DICTIONARIES) List<SimpleEntity> findScChambers(); @Cacheable(DICTIONARIES) List<SimpleEntity> findScChamberDivisions(long chamberId); @Cacheable(DICTIONARIES) List<SimpleEntity> findScJudgmentForms(); @Autowired void setScChamberRepository(ScChamberRepository scChamberRepository); @Autowired void setScChamberDivisionRepository(ScChamberDivisionRepository scChamberDivisionRepository); @Autowired void setScJudgmentFormRepository(ScJudgmentFormRepository scJudgmentFormRepository); @Autowired void setSimpleEntityConverter(SimpleEntityConverter simpleEntityConverter); }
ScListService { @Cacheable(DICTIONARIES) public List<SimpleEntity> findScChamberDivisions(long chamberId) { List<SupremeCourtChamberDivision> chamberDivisions = scChamberDivisionRepository.findAllByScChamberId(chamberId); Collections.sort(chamberDivisions, new ScChamberDivisionComparator()); return simpleEntityConverter.convertScChamberDivisions(chamberDivisions); }  @Cacheable(DICTIONARIES) List<SimpleEntity> findScChambers(); @Cacheable(DICTIONARIES) List<SimpleEntity> findScChamberDivisions(long chamberId); @Cacheable(DICTIONARIES) List<SimpleEntity> findScJudgmentForms(); @Autowired void setScChamberRepository(ScChamberRepository scChamberRepository); @Autowired void setScChamberDivisionRepository(ScChamberDivisionRepository scChamberDivisionRepository); @Autowired void setScJudgmentFormRepository(ScJudgmentFormRepository scJudgmentFormRepository); @Autowired void setSimpleEntityConverter(SimpleEntityConverter simpleEntityConverter);  }