### Question:
EnrichmentTagUploadService { @Transactional public void uploadEnrichmentTags(InputStream inputStream) { uploadEnrichmentTagRepository.truncate(); if (inputStream == null) { throw new ServiceException(ERROR_EMPTY_DATA, "no data received, null input stream"); } try { try (LimitedInputStream limitedInputStream = limitInputStream(inputStream, enrichmentTagMaxUploadSize)) { JsonParser jsonParser = jsonFactory.createParser(limitedInputStream); EnrichmentTagItem enrichmentTagItem = null; JsonToken token = jsonParser.nextToken(); if (token == null) { throw new ServiceException(ERROR_EMPTY_DATA, "no data received, empty message body"); } if (!JsonToken.START_ARRAY.equals(token)) { throw new ServiceException(ERROR_INVALID_JSON_FORMAT, "the content is not a json array"); } do { enrichmentTagItem = jsonObjectIterator.nextJsonObject(jsonParser, EnrichmentTagItem.class); if (enrichmentTagItem == null) { return; } enrichmentTagItemUploadProcessor.processEnrichmentTagItem(enrichmentTagItem); } while (true); } } catch (JsonParseException e) { throw new ServiceException(ERROR_INVALID_JSON_FORMAT, e.getMessage(), e); } catch (JsonMappingException e) { throw new ServiceException(ERROR_INVALID_JSON_FORMAT, e.getMessage(), e); } catch (ValidationException e) { throw new ServiceException(ERROR_INVALID_DATA, e.getMessage(), e); } catch (IOException e) { throw new ServiceException(ERROR_IO, e.getMessage(), e); } catch (PersistenceException e) { if (e.getCause() instanceof ConstraintViolationException) { throw new ServiceException(ERROR_SAME_TAG_ALREADY_UPLOADED, e.getCause().getMessage(), e.getCause()); } else { throw new ServiceException(ERROR_INTERVAL_SERVER_ERROR, e.getMessage(), e.getCause()); } } }  @Transactional void uploadEnrichmentTags(InputStream inputStream); long getEnrichmentTagMaxUploadSize(); @Value("${enrichment.enrichmentTagMaxUploadSizeInBytes}") void setEnrichmentTagMaxUploadSize(long enrichmentTagMaxUploadSize); @Autowired void setJsonFactory(JsonFactory jsonFactory); @Autowired void setEnrichmentTagItemUploadProcessor(EnrichmentTagItemUploadProcessor enrichmentTagItemUploadProcessor); @Autowired void setJsonObjectIterator(JsonObjectIterator jsonObjectIterator); @Autowired void setUploadEnrichmentTagRepository(UploadEnrichmentTagRepository uploadEnrichmentTagRepository);  }### Answer:
@Test public void uploadEnrichmentTags() throws Exception { InputStream inputStream = mock(InputStream.class); EnrichmentTagItem enrichmentTagItem = mock(EnrichmentTagItem.class); when(jsonFactory.createParser(Mockito.any(InputStream.class))).thenReturn(jsonParser); when(jsonParser.nextToken()).thenReturn(JsonToken.START_ARRAY); when(jsonObjectIterator.nextJsonObject(jsonParser, EnrichmentTagItem.class)).thenReturn(enrichmentTagItem, (EnrichmentTagItem)null); enrichmentTagUploadService.uploadEnrichmentTags(inputStream); InOrder inOrder = Mockito.inOrder(uploadEnrichmentTagRepository, jsonFactory, jsonObjectIterator, enrichmentTagItemUploadProcessor); inOrder.verify(uploadEnrichmentTagRepository).truncate(); ArgumentCaptor<InputStream> inputStreamArg = ArgumentCaptor.forClass(InputStream.class); inOrder.verify(jsonFactory).createParser(inputStreamArg.capture()); assertTrue(inputStreamArg.getValue() instanceof LimitedInputStream); inOrder.verify(jsonObjectIterator).nextJsonObject(jsonParser, EnrichmentTagItem.class); ArgumentCaptor<EnrichmentTagItem> tagItemToProcessArg = ArgumentCaptor.forClass(EnrichmentTagItem.class); inOrder.verify(enrichmentTagItemUploadProcessor).processEnrichmentTagItem(tagItemToProcessArg.capture()); assertTrue(enrichmentTagItem == tagItemToProcessArg.getValue()); inOrder.verify(jsonObjectIterator).nextJsonObject(jsonParser, EnrichmentTagItem.class); verifyNoMoreInteractions(jsonFactory, jsonObjectIterator, enrichmentTagItemUploadProcessor); }