@Test public void findScChambers_correct_order() { SupremeCourtChamber scChamberOne = new SupremeCourtChamber(); scChamberOne.setName("Izba Pracy, Ubezpieczeń Społecznych i Spraw Publicznych"); SupremeCourtChamber scChamberTwo = new SupremeCourtChamber(); scChamberTwo.setName("Izba Wojskowa"); SimpleEntity simpleScChamberOne = new SimpleEntity(); simpleScChamberOne.setName("Izba Pracy, Ubezpieczeń Społecznych i Spraw Publicznych"); SimpleEntity simpleScChamberTwo = new SimpleEntity(); simpleScChamberTwo.setName("Izba Wojskowa"); List<SupremeCourtChamber> chambersWrongOrder = Arrays.asList(scChamberTwo, scChamberOne); List<SupremeCourtChamber> chambersRightOrder = Arrays.asList(scChamberOne, scChamberTwo); when(scChamberRepository.findAll()).thenReturn(chambersWrongOrder); when(simpleEntityConverter.convertScChambers(chambersRightOrder)).thenReturn(Arrays.asList(simpleScChamberOne, simpleScChamberTwo)); List<SimpleEntity> chambers = scListService.findScChambers(); assertEquals(2, chambers.size()); assertEquals(chambers.get(0).getName(), scChamberOne.getName()); assertEquals(chambers.get(1).getName(), scChamberTwo.getName()); }
@Cacheable(DICTIONARIES) public List<SimpleEntity> findScChambers() { List<SupremeCourtChamber> chambers = scChamberRepository.findAll(); Collections.sort(chambers, new ScChamberComparator()); return simpleEntityConverter.convertScChambers(chambers); }
ScListService { @Cacheable(DICTIONARIES) public List<SimpleEntity> findScChambers() { List<SupremeCourtChamber> chambers = scChamberRepository.findAll(); Collections.sort(chambers, new ScChamberComparator()); return simpleEntityConverter.convertScChambers(chambers); } }
ScListService { @Cacheable(DICTIONARIES) public List<SimpleEntity> findScChambers() { List<SupremeCourtChamber> chambers = scChamberRepository.findAll(); Collections.sort(chambers, new ScChamberComparator()); return simpleEntityConverter.convertScChambers(chambers); }  }
ScListService { @Cacheable(DICTIONARIES) public List<SimpleEntity> findScChambers() { List<SupremeCourtChamber> chambers = scChamberRepository.findAll(); Collections.sort(chambers, new ScChamberComparator()); return simpleEntityConverter.convertScChambers(chambers); }  @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> findScChambers() { List<SupremeCourtChamber> chambers = scChamberRepository.findAll(); Collections.sort(chambers, new ScChamberComparator()); return simpleEntityConverter.convertScChambers(chambers); }  @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);  }