@Test public void successBatchDetectEntitiesCall() { when(mockComprehendClient.batchDetectEntities(any(BatchDetectEntitiesRequest.class))) .thenReturn(mockBatchDetectEntitiesResult); BatchResponse result = test.sendBatchRequest( TestConstants.FIELD_LOCATOR_LIST, TestConstants.CONTENT_LIST, TestConstants.LANGUAGE_CODE, mockComprehendClient); assertEquals(TestConstants.FIELD_LOCATOR_LIST, result.getLocatorList()); }
@Override public BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList, @NonNull final List<String> contentList, @NonNull final LanguageCode languageCode, @NonNull final AmazonComprehend comprehendClient) { BatchDetectEntitiesRequest request = new BatchDetectEntitiesRequest().withTextList(contentList).withLanguageCode(languageCode.toString()); BatchDetectEntitiesResult batchDetectEntitiesResult = comprehendClient.batchDetectEntities(request); List<JSONObject> flattenedEntityList = new ArrayList<>(); for (BatchDetectEntitiesItemResult resultItem : batchDetectEntitiesResult.getResultList()) { flattenedEntityList.add(flattenEntityList(resultItem.getEntities())); } return new BatchResponse<>( fieldLocatorList, batchDetectEntitiesResult.getResultList(), batchDetectEntitiesResult.getErrorList(), flattenedEntityList); }
DetectEntities implements ComprehendOperation { @Override public BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList, @NonNull final List<String> contentList, @NonNull final LanguageCode languageCode, @NonNull final AmazonComprehend comprehendClient) { BatchDetectEntitiesRequest request = new BatchDetectEntitiesRequest().withTextList(contentList).withLanguageCode(languageCode.toString()); BatchDetectEntitiesResult batchDetectEntitiesResult = comprehendClient.batchDetectEntities(request); List<JSONObject> flattenedEntityList = new ArrayList<>(); for (BatchDetectEntitiesItemResult resultItem : batchDetectEntitiesResult.getResultList()) { flattenedEntityList.add(flattenEntityList(resultItem.getEntities())); } return new BatchResponse<>( fieldLocatorList, batchDetectEntitiesResult.getResultList(), batchDetectEntitiesResult.getErrorList(), flattenedEntityList); } }
DetectEntities implements ComprehendOperation { @Override public BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList, @NonNull final List<String> contentList, @NonNull final LanguageCode languageCode, @NonNull final AmazonComprehend comprehendClient) { BatchDetectEntitiesRequest request = new BatchDetectEntitiesRequest().withTextList(contentList).withLanguageCode(languageCode.toString()); BatchDetectEntitiesResult batchDetectEntitiesResult = comprehendClient.batchDetectEntities(request); List<JSONObject> flattenedEntityList = new ArrayList<>(); for (BatchDetectEntitiesItemResult resultItem : batchDetectEntitiesResult.getResultList()) { flattenedEntityList.add(flattenEntityList(resultItem.getEntities())); } return new BatchResponse<>( fieldLocatorList, batchDetectEntitiesResult.getResultList(), batchDetectEntitiesResult.getErrorList(), flattenedEntityList); }  }
DetectEntities implements ComprehendOperation { @Override public BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList, @NonNull final List<String> contentList, @NonNull final LanguageCode languageCode, @NonNull final AmazonComprehend comprehendClient) { BatchDetectEntitiesRequest request = new BatchDetectEntitiesRequest().withTextList(contentList).withLanguageCode(languageCode.toString()); BatchDetectEntitiesResult batchDetectEntitiesResult = comprehendClient.batchDetectEntities(request); List<JSONObject> flattenedEntityList = new ArrayList<>(); for (BatchDetectEntitiesItemResult resultItem : batchDetectEntitiesResult.getResultList()) { flattenedEntityList.add(flattenEntityList(resultItem.getEntities())); } return new BatchResponse<>( fieldLocatorList, batchDetectEntitiesResult.getResultList(), batchDetectEntitiesResult.getErrorList(), flattenedEntityList); }  @Override String[] getVisualizationNameList(); @Override SingularResponse sendSingularRequest(@NonNull final String fieldNameAndOperation,
                                                @NonNull final String content,
                                                @NonNull final LanguageCode languageCode,
                                                @NonNull final AmazonComprehend comprehendClient); @Override BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList,
                                          @NonNull final List<String> contentList,
                                          @NonNull final LanguageCode languageCode,
                                          @NonNull final AmazonComprehend comprehendClient); }
DetectEntities implements ComprehendOperation { @Override public BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList, @NonNull final List<String> contentList, @NonNull final LanguageCode languageCode, @NonNull final AmazonComprehend comprehendClient) { BatchDetectEntitiesRequest request = new BatchDetectEntitiesRequest().withTextList(contentList).withLanguageCode(languageCode.toString()); BatchDetectEntitiesResult batchDetectEntitiesResult = comprehendClient.batchDetectEntities(request); List<JSONObject> flattenedEntityList = new ArrayList<>(); for (BatchDetectEntitiesItemResult resultItem : batchDetectEntitiesResult.getResultList()) { flattenedEntityList.add(flattenEntityList(resultItem.getEntities())); } return new BatchResponse<>( fieldLocatorList, batchDetectEntitiesResult.getResultList(), batchDetectEntitiesResult.getErrorList(), flattenedEntityList); }  @Override String[] getVisualizationNameList(); @Override SingularResponse sendSingularRequest(@NonNull final String fieldNameAndOperation,
                                                @NonNull final String content,
                                                @NonNull final LanguageCode languageCode,
                                                @NonNull final AmazonComprehend comprehendClient); @Override BatchResponse sendBatchRequest(@NonNull final List<BatchFieldLocator> fieldLocatorList,
                                          @NonNull final List<String> contentList,
                                          @NonNull final LanguageCode languageCode,
                                          @NonNull final AmazonComprehend comprehendClient);  }