### Question:
UpdateEnrichmentHashProcessor implements ItemProcessor<JudgmentEnrichmentTags, JudgmentEnrichmentHash> { @Override public JudgmentEnrichmentHash process(JudgmentEnrichmentTags judgmentEnrichmentTags) throws Exception { JudgmentEnrichmentHash enrichmentHash = judgmentEnrichmentHashRepository.findByJudgmentId(judgmentEnrichmentTags.getJudgmentId()); if (enrichmentHash == null) { enrichmentHash = new JudgmentEnrichmentHash(); enrichmentHash.setJudgmentId(judgmentEnrichmentTags.getJudgmentId()); } String hash = judgmentEnrichmentTagsHashCalculator.calculateHash(judgmentEnrichmentTags); enrichmentHash.updateHash(hash); return enrichmentHash; }  @Override JudgmentEnrichmentHash process(JudgmentEnrichmentTags judgmentEnrichmentTags); @Autowired void setJudgmentEnrichmentTagsHashCalculator(
            JudgmentEnrichmentTagsHashCalculator judgmentEnrichmentTagsHashCalculator); @Autowired void setJudgmentEnrichmentHashRepository(
            JudgmentEnrichmentHashRepository judgmentEnrichmentHashRepository);  }### Answer:
@Test public void process_NEW_HASH() throws Exception { JudgmentEnrichmentTags judgmentEnrichmentTags = new JudgmentEnrichmentTags(2L); when(judgmentEnrichmentTagsHashCalculator.calculateHash(judgmentEnrichmentTags)).thenReturn("hash"); when(judgmentEnrichmentHashRepository.findByJudgmentId(2L)).thenReturn(null); JudgmentEnrichmentHash retJudgmentEnrichmentHash = updateEnrichmentHashProcessor.process(judgmentEnrichmentTags); assertEquals(2L, retJudgmentEnrichmentHash.getJudgmentId()); assertEquals(null, retJudgmentEnrichmentHash.getOldHash()); assertEquals("hash", retJudgmentEnrichmentHash.getHash()); assertFalse(retJudgmentEnrichmentHash.isProcessed()); }
@Test public void process_UPDATE_EXISTING_HASH() throws Exception { JudgmentEnrichmentTags judgmentEnrichmentTags = new JudgmentEnrichmentTags(2L); JudgmentEnrichmentHash judgmentEnrichmentHash = mock(JudgmentEnrichmentHash.class); when(judgmentEnrichmentTagsHashCalculator.calculateHash(judgmentEnrichmentTags)).thenReturn("hash"); when(judgmentEnrichmentHashRepository.findByJudgmentId(2L)).thenReturn(judgmentEnrichmentHash); JudgmentEnrichmentHash retJudgmentEnrichmentHash = updateEnrichmentHashProcessor.process(judgmentEnrichmentTags); assertTrue(retJudgmentEnrichmentHash == judgmentEnrichmentHash); verify(judgmentEnrichmentHash).updateHash("hash"); verifyNoMoreInteractions(judgmentEnrichmentHash); }