### Question:
JudgmentCorrectionService { public List<JudgmentCorrection> findAllByJudgmentIdSorted(long judgmentId) { List<JudgmentCorrection> judgmentCorrections = judgmentCorrectionRepository.findAllByJudgmentId(judgmentId); Collections.sort(judgmentCorrections, new JudgmentCorrectionComparator()); return judgmentCorrections; }  List<JudgmentCorrection> findAllByJudgmentIdSorted(long judgmentId); @Autowired void setJudgmentCorrectionRepository(JudgmentCorrectionRepository judgmentCorrectionRepository);  }### Answer:
@Test public void findByJugmentId_CommonCourtJudgment() { int judgmentId = 123; List<JudgmentCorrection> unsortedJc = Lists.newArrayList(); unsortedJc.add(createJcJudgeDelete(ccJudgment)); unsortedJc.add(createJcCommonCourtJudgment()); unsortedJc.add(createJcJudgeUpdate(ccJudgment)); List<JudgmentCorrection> expectedJc = Lists.newArrayList(); expectedJc.add(createJcCommonCourtJudgment()); expectedJc.add(createJcJudgeUpdate(ccJudgment)); expectedJc.add(createJcJudgeDelete(ccJudgment)); when(judgmentCorrectionRepository.findAllByJudgmentId(judgmentId)).thenReturn(unsortedJc); List<JudgmentCorrection> actualJc = judgmentCorrectionService.findAllByJudgmentIdSorted(judgmentId); assertEquals(expectedJc, actualJc); }
@Test public void findByJugmentId_SupremeCourtJudgment() { int judgmentId = 124; List<JudgmentCorrection> unsortedJc = Lists.newArrayList(); unsortedJc.add(createJcSupremeCourtChamber()); unsortedJc.add(createJcJudgeDelete(scJudgment)); unsortedJc.add(createJcSupremeCourtJudgmentForm()); unsortedJc.add(createJcSupremeCourtJudgment()); unsortedJc.add(createJcJudgeUpdate(scJudgment)); List<JudgmentCorrection> expectedJc = Lists.newArrayList(); expectedJc.add(createJcSupremeCourtJudgment()); expectedJc.add(createJcSupremeCourtChamber()); expectedJc.add(createJcSupremeCourtJudgmentForm()); expectedJc.add(createJcJudgeUpdate(scJudgment)); expectedJc.add(createJcJudgeDelete(scJudgment)); when(judgmentCorrectionRepository.findAllByJudgmentId(judgmentId)).thenReturn(unsortedJc); List<JudgmentCorrection> actualJc = judgmentCorrectionService.findAllByJudgmentIdSorted(judgmentId); assertEquals(expectedJc, actualJc); }