Class ElasticsearchRule

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class ElasticsearchRule
    extends org.junit.rules.ExternalResource
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HOST  
      static int PORT  
      static java.lang.String VITAM_CLUSTER  
    • Constructor Summary

      Constructors 
      Constructor Description
      ElasticsearchRule​(java.lang.String... indexesToBePurged)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ElasticsearchRule addIndexToBePurged​(java.lang.String indexName)  
      protected void after()  
      void close()  
      boolean createIndex​(java.lang.String aliasName, java.lang.String indexName, java.lang.String mapping)  
      void deleteIndexesWithoutClose()  
      boolean existsIndex​(java.lang.String indexName)  
      org.elasticsearch.client.RestHighLevelClient getClient()
      get the Client
      static java.lang.String getClusterName()
      get the cluster name
      static java.lang.String getHost()  
      static int getPort()
      get the tcp port
      void handleAfter()
      Used when annotated @ClassRule
      void handleAfter​(java.util.Set<java.lang.String> indexesToBePurged)  
      void handlePurge​(org.elasticsearch.client.RestHighLevelClient client, java.lang.String index, org.elasticsearch.index.query.QueryBuilder qb)  
      void purge​(org.elasticsearch.client.RestHighLevelClient client, java.lang.String indexName)  
      void purgeIndex​(org.elasticsearch.client.RestHighLevelClient client, java.lang.String indexName)  
      void purgeIndices()  
      • Methods inherited from class org.junit.rules.ExternalResource

        apply, before
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ElasticsearchRule

        public ElasticsearchRule​(java.lang.String... indexesToBePurged)
    • Method Detail

      • after

        protected void after()
        Overrides:
        after in class org.junit.rules.ExternalResource
      • purge

        public void purge​(org.elasticsearch.client.RestHighLevelClient client,
                          java.lang.String indexName)
      • handlePurge

        public void handlePurge​(org.elasticsearch.client.RestHighLevelClient client,
                                java.lang.String index,
                                org.elasticsearch.index.query.QueryBuilder qb)
      • existsIndex

        public boolean existsIndex​(java.lang.String indexName)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • createIndex

        public boolean createIndex​(java.lang.String aliasName,
                                   java.lang.String indexName,
                                   java.lang.String mapping)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • purgeIndex

        public final void purgeIndex​(org.elasticsearch.client.RestHighLevelClient client,
                                     java.lang.String indexName)
      • deleteIndexesWithoutClose

        public void deleteIndexesWithoutClose()
      • purgeIndices

        public void purgeIndices()
      • addIndexToBePurged

        public ElasticsearchRule addIndexToBePurged​(java.lang.String indexName)
      • handleAfter

        public void handleAfter()
        Used when annotated @ClassRule
      • handleAfter

        public void handleAfter​(java.util.Set<java.lang.String> indexesToBePurged)
      • getClusterName

        public static java.lang.String getClusterName()
        get the cluster name
        Returns:
        the vitam cluster name
      • getPort

        public static int getPort()
        get the tcp port
        Returns:
        TCP_PORT
      • getHost

        public static java.lang.String getHost()
      • getClient

        public org.elasticsearch.client.RestHighLevelClient getClient()
        get the Client
        Returns:
        the client
      • close

        public void close()