@Test public void extractJudges() { String janNowak = "Jan Nowak"; String adamKowalski = "Adam Kowalski"; String wrongName = "!! 11"; SourceJudge sourceJudge1 = new SourceJudge(); sourceJudge1.setName(janNowak); sourceJudge1.setFunction("SSN"); sourceJudge1.setSpecialRoles(Lists.newArrayList(JudgeRole.PRESIDING_JUDGE.name(), JudgeRole.REPORTING_JUDGE.name())); SourceJudge sourceJudge2 = new SourceJudge(); sourceJudge2.setName(adamKowalski); sourceJudge2.setFunction("SSA"); SourceJudge sourceJudge3 = new SourceJudge(); sourceJudge3.setName(wrongName); SourceJudge sourceJudgeBlank = new SourceJudge(); sJudgment.setJudges(Lists.newArrayList(sourceJudge1, sourceJudge2, sourceJudge3, sourceJudgeBlank)); Judge judgeJanNowak = new Judge(janNowak, JudgeRole.PRESIDING_JUDGE, JudgeRole.REPORTING_JUDGE); Judge judgeAdamKowalski = new Judge(adamKowalski); when(judgeConverter.convertJudge(janNowak, Lists.newArrayList(JudgeRole.PRESIDING_JUDGE, JudgeRole.REPORTING_JUDGE), correctionList)).thenReturn(judgeJanNowak); when(judgeConverter.convertJudge(adamKowalski, Lists.newArrayList(), correctionList)).thenReturn(judgeAdamKowalski); when(judgeConverter.convertJudge(wrongName, Lists.newArrayList(), correctionList)).thenReturn(null); List<Judge> judges = sourceJudgeExtractorHelper.extractJudges(sJudgment, correctionList); assertEquals(2, judges.size()); for (Judge judge : judges) { sJudgment.getJudges().contains(judge.getName()); if (judge.getName().equals(sourceJudge1.getName())) { assertThat(judge.getSpecialRoles(), Matchers.containsInAnyOrder(JudgeRole.PRESIDING_JUDGE, JudgeRole.REPORTING_JUDGE)); assertEquals(sourceJudge1.getFunction(), judge.getFunction()); } else { assertThat(judge.getSpecialRoles(), Matchers.containsInAnyOrder(sourceJudge2.getSpecialRoles().toArray())); assertEquals(sourceJudge2.getFunction(), judge.getFunction()); } } }
public List<Judge> extractJudges(SourceJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); for (SourceJudge sourceJudge : sourceJudgment.getJudges()) { List<JudgeRole> roles = sourceJudge.getSpecialRoles().stream().map(role->JudgeRole.valueOf(role)).collect(Collectors.toList()); Judge judge = judgeConverter.convertJudge(sourceJudge.getName(), roles, correctionList); if (judge != null) { judge.setFunction(sourceJudge.getFunction()); judges.add(judge); } } return judges; }
SourceJudgeExtractorHelper { public List<Judge> extractJudges(SourceJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); for (SourceJudge sourceJudge : sourceJudgment.getJudges()) { List<JudgeRole> roles = sourceJudge.getSpecialRoles().stream().map(role->JudgeRole.valueOf(role)).collect(Collectors.toList()); Judge judge = judgeConverter.convertJudge(sourceJudge.getName(), roles, correctionList); if (judge != null) { judge.setFunction(sourceJudge.getFunction()); judges.add(judge); } } return judges; } }
SourceJudgeExtractorHelper { public List<Judge> extractJudges(SourceJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); for (SourceJudge sourceJudge : sourceJudgment.getJudges()) { List<JudgeRole> roles = sourceJudge.getSpecialRoles().stream().map(role->JudgeRole.valueOf(role)).collect(Collectors.toList()); Judge judge = judgeConverter.convertJudge(sourceJudge.getName(), roles, correctionList); if (judge != null) { judge.setFunction(sourceJudge.getFunction()); judges.add(judge); } } return judges; }  }
SourceJudgeExtractorHelper { public List<Judge> extractJudges(SourceJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); for (SourceJudge sourceJudge : sourceJudgment.getJudges()) { List<JudgeRole> roles = sourceJudge.getSpecialRoles().stream().map(role->JudgeRole.valueOf(role)).collect(Collectors.toList()); Judge judge = judgeConverter.convertJudge(sourceJudge.getName(), roles, correctionList); if (judge != null) { judge.setFunction(sourceJudge.getFunction()); judges.add(judge); } } return judges; }  List<Judge> extractJudges(SourceJudgment sourceJudgment, ImportCorrectionList correctionList); @Autowired void setJudgeConverter(JudgeConverter judgeConverter); }
SourceJudgeExtractorHelper { public List<Judge> extractJudges(SourceJudgment sourceJudgment, ImportCorrectionList correctionList) { List<Judge> judges = Lists.newArrayList(); for (SourceJudge sourceJudge : sourceJudgment.getJudges()) { List<JudgeRole> roles = sourceJudge.getSpecialRoles().stream().map(role->JudgeRole.valueOf(role)).collect(Collectors.toList()); Judge judge = judgeConverter.convertJudge(sourceJudge.getName(), roles, correctionList); if (judge != null) { judge.setFunction(sourceJudge.getFunction()); judges.add(judge); } } return judges; }  List<Judge> extractJudges(SourceJudgment sourceJudgment, ImportCorrectionList correctionList); @Autowired void setJudgeConverter(JudgeConverter judgeConverter);  }