### Question:
EnrichmentTagItemUploadProcessor { public void processEnrichmentTagItem(EnrichmentTagItem enrichmentTagItem) { commonValidator.validateEx(enrichmentTagItem); UploadEnrichmentTag uploadEnrichmentTag = enrichmentTagItemConverter.convertEnrichmentTagItem(enrichmentTagItem); uploadEnrichmentTagRepository.saveAndFlush(uploadEnrichmentTag); entityManager.clear(); }  void processEnrichmentTagItem(EnrichmentTagItem enrichmentTagItem); @Autowired void setEnrichmentTagItemConverter(EnrichmentTagItemConverter enrichmentTagItemConverter); @Autowired void setUploadEnrichmentTagRepository(UploadEnrichmentTagRepository uploadEnrichmentTagRepository); @Autowired void setCommonValidator(CommonValidator commonValidator); @Autowired void setEntityManager(EntityManager entityManager);  }### Answer:
@Test public void processEnrichmentTagItem() { EnrichmentTagItem enrichmentTagItem = mock(EnrichmentTagItem.class); UploadEnrichmentTag uploadEnrichmentTag = mock(UploadEnrichmentTag.class); when(enrichmentTagItemConverter.convertEnrichmentTagItem(enrichmentTagItem)).thenReturn(uploadEnrichmentTag); enrichmentTagItemUploadProcessor.processEnrichmentTagItem(enrichmentTagItem); ArgumentCaptor<EnrichmentTagItem> enrichmentTagItemArg = ArgumentCaptor.forClass(EnrichmentTagItem.class); verify(commonValidator).validateEx(enrichmentTagItemArg.capture()); assertTrue(enrichmentTagItem == enrichmentTagItemArg.getValue()); ArgumentCaptor<UploadEnrichmentTag> uploadEnrichmentTagArg = ArgumentCaptor.forClass(UploadEnrichmentTag.class); verify(uploadEnrichmentTagRepository).saveAndFlush(uploadEnrichmentTagArg.capture()); assertTrue(uploadEnrichmentTag == uploadEnrichmentTagArg.getValue()); verify(entityManager).clear(); }
@Test(expected=ValidationException.class) public void processEnrichmentTagItem_ValidationError() throws Exception { EnrichmentTagItem enrichmentTagItem = mock(EnrichmentTagItem.class); Mockito.doThrow(ValidationException.class).when(commonValidator).validateEx(enrichmentTagItem); enrichmentTagItemUploadProcessor.processEnrichmentTagItem(enrichmentTagItem); }