@Test public void convert_nameCorrection() { String judgeName = " Jan Nowak!! "; String normalizedJudgeName = "Jan Nowak"; when(judgeNameNormalizer.normalize(judgeName)).thenReturn(normalizedJudgeName); Judge judge = judgeConverter.convertJudge(judgeName, correctionList); assertNotNull(judge); assertEquals(normalizedJudgeName, judge.getName()); assertEquals(0, judge.getSpecialRoles().size()); assertEquals(1, correctionList.getNumberOfCorrections()); correctionList.hasImportCorrection(createUpdate(judge).ofProperty(NAME).oldValue(judgeName).newValue(normalizedJudgeName).build()); }
public Judge convertJudge(String judgeName, List<JudgeRole> specialRoles, ImportCorrectionList correctionList) { Preconditions.checkNotNull(correctionList); String normalizedJudgeName = judgeNameNormalizer.normalize(judgeName); if (StringUtils.isBlank(normalizedJudgeName)) { correctionList.addCorrection(createDelete(Judge.class).oldValue(judgeName).newValue(null).build()); return null; } Judge judge = new Judge(normalizedJudgeName, specialRoles); if (!(PersonNameNormalizer.unify(judgeName).equals(toRootLowerCase(normalizedJudgeName)))) { correctionList.addCorrection(createUpdate(judge) .ofProperty(CorrectedProperty.NAME).oldValue(judgeName).newValue(normalizedJudgeName) .build()); } return judge; }
JudgeConverter { public Judge convertJudge(String judgeName, List<JudgeRole> specialRoles, ImportCorrectionList correctionList) { Preconditions.checkNotNull(correctionList); String normalizedJudgeName = judgeNameNormalizer.normalize(judgeName); if (StringUtils.isBlank(normalizedJudgeName)) { correctionList.addCorrection(createDelete(Judge.class).oldValue(judgeName).newValue(null).build()); return null; } Judge judge = new Judge(normalizedJudgeName, specialRoles); if (!(PersonNameNormalizer.unify(judgeName).equals(toRootLowerCase(normalizedJudgeName)))) { correctionList.addCorrection(createUpdate(judge) .ofProperty(CorrectedProperty.NAME).oldValue(judgeName).newValue(normalizedJudgeName) .build()); } return judge; } }
JudgeConverter { public Judge convertJudge(String judgeName, List<JudgeRole> specialRoles, ImportCorrectionList correctionList) { Preconditions.checkNotNull(correctionList); String normalizedJudgeName = judgeNameNormalizer.normalize(judgeName); if (StringUtils.isBlank(normalizedJudgeName)) { correctionList.addCorrection(createDelete(Judge.class).oldValue(judgeName).newValue(null).build()); return null; } Judge judge = new Judge(normalizedJudgeName, specialRoles); if (!(PersonNameNormalizer.unify(judgeName).equals(toRootLowerCase(normalizedJudgeName)))) { correctionList.addCorrection(createUpdate(judge) .ofProperty(CorrectedProperty.NAME).oldValue(judgeName).newValue(normalizedJudgeName) .build()); } return judge; }  }
JudgeConverter { public Judge convertJudge(String judgeName, List<JudgeRole> specialRoles, ImportCorrectionList correctionList) { Preconditions.checkNotNull(correctionList); String normalizedJudgeName = judgeNameNormalizer.normalize(judgeName); if (StringUtils.isBlank(normalizedJudgeName)) { correctionList.addCorrection(createDelete(Judge.class).oldValue(judgeName).newValue(null).build()); return null; } Judge judge = new Judge(normalizedJudgeName, specialRoles); if (!(PersonNameNormalizer.unify(judgeName).equals(toRootLowerCase(normalizedJudgeName)))) { correctionList.addCorrection(createUpdate(judge) .ofProperty(CorrectedProperty.NAME).oldValue(judgeName).newValue(normalizedJudgeName) .build()); } return judge; }  Judge convertJudge(String judgeName, List<JudgeRole> specialRoles, ImportCorrectionList correctionList); Judge convertJudge(String judgeName, ImportCorrectionList correctionList); @Autowired void setJudgeNameNormalizer(JudgeNameNormalizer judgeNameNormalizer); }
JudgeConverter { public Judge convertJudge(String judgeName, List<JudgeRole> specialRoles, ImportCorrectionList correctionList) { Preconditions.checkNotNull(correctionList); String normalizedJudgeName = judgeNameNormalizer.normalize(judgeName); if (StringUtils.isBlank(normalizedJudgeName)) { correctionList.addCorrection(createDelete(Judge.class).oldValue(judgeName).newValue(null).build()); return null; } Judge judge = new Judge(normalizedJudgeName, specialRoles); if (!(PersonNameNormalizer.unify(judgeName).equals(toRootLowerCase(normalizedJudgeName)))) { correctionList.addCorrection(createUpdate(judge) .ofProperty(CorrectedProperty.NAME).oldValue(judgeName).newValue(normalizedJudgeName) .build()); } return judge; }  Judge convertJudge(String judgeName, List<JudgeRole> specialRoles, ImportCorrectionList correctionList); Judge convertJudge(String judgeName, ImportCorrectionList correctionList); @Autowired void setJudgeNameNormalizer(JudgeNameNormalizer judgeNameNormalizer);  }