Class ElasticsearchRule
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- fr.gouv.vitam.common.elasticsearch.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 Clientstatic java.lang.String
getClusterName()
get the cluster namestatic java.lang.String
getHost()
static int
getPort()
get the tcp portvoid
handleAfter()
Used when annotated @ClassRulevoid
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()
-
-
-
Field Detail
-
PORT
public static final int PORT
- See Also:
- Constant Field Values
-
HOST
public static java.lang.String HOST
-
VITAM_CLUSTER
public static final java.lang.String VITAM_CLUSTER
- See Also:
- Constant Field Values
-
-
Method Detail
-
after
protected void after()
- Overrides:
after
in classorg.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()
-
-