public synchronized boolean createIndex(String indexName)
      throws ElasticsearchResourceManagerException {
    LOG.info("Creating index using name '{}'.", indexName);

    try {
      // Check to see if the index exists
      if (indexExists(indexName)) {
        return false;
      }

      managedIndexNames.add(indexName);

      return elasticsearchClient
          .indices()
          .create(new CreateIndexRequest(indexName), RequestOptions.DEFAULT)
          .isAcknowledged();
    } catch (Exception e) {
      throw new ElasticsearchResourceManagerException("Error creating index.", e);
    }
  }
@Test
  public void testCreateCollectionShouldReturnTrueIfElasticsearchDoesNotThrowAnyError()
      throws IOException {
    when(elasticsearchClient
            .indices()
            .exists(any(GetIndexRequest.class), eq(RequestOptions.DEFAULT)))
        .thenReturn(false);
    when(elasticsearchClient
            .indices()
            .create(any(CreateIndexRequest.class), eq(RequestOptions.DEFAULT))
            .isAcknowledged())
        .thenReturn(true);

    assertThat(testManager.createIndex(INDEX_NAME)).isEqualTo(true);
    verify(elasticsearchClient.indices())
        .exists(any(GetIndexRequest.class), eq(RequestOptions.DEFAULT));
  }