Search in sources :

Example 61 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class AbsoluteSearchResourceTest method searchForExistingKeyword.

@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForExistingKeyword() {
    final ValidatableResponse result = doSearchFor("Testmessage");
    final JsonPath response = result.statusCode(200).extract().jsonPath();
    assertThat(response.getInt("total_results")).isEqualTo(1);
    assertThat(response.getList("messages")).hasSize(1);
    assertThat(response.getList("used_indices")).hasSize(1);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) JsonPath(com.jayway.restassured.path.json.JsonPath) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 62 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class AbsoluteSearchResourceTest method searchForExistingKeywordInsideOfVeryNarrowTimeRange.

@Test
@UsingDataSet(locations = "searchForExistingKeyword.json")
public void searchForExistingKeywordInsideOfVeryNarrowTimeRange() {
    final ValidatableResponse result = doSearchFor("Testmessage", "2015-06-16T11:32:16.827Z", "2015-06-16T11:32:16.827Z");
    final JsonPath response = result.statusCode(200).extract().jsonPath();
    assertThat(response.getInt("total_results")).isEqualTo(1);
    assertThat(response.getList("messages")).isNotEmpty();
    assertThat(response.getList("used_indices")).hasSize(1);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) JsonPath(com.jayway.restassured.path.json.JsonPath) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 63 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class IndicesGetAllMessageFieldsTest method GetAllMessageFieldsForIndicesForNonexistingIndexShouldReturnEmptySet.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void GetAllMessageFieldsForIndicesForNonexistingIndexShouldReturnEmptySet() throws Exception {
    final String[] indexNames = new String[] { "graylog_0" };
    final IndicesExistsResponse response = client.admin().indices().exists(new IndicesExistsRequest("graylog_0")).get();
    assertThat(response.isExists()).isFalse();
    final Map<String, Set<String>> result = indices.getAllMessageFieldsForIndices(indexNames);
    assertThat(result).isNotNull().isEmpty();
}
Also used : Set(java.util.Set) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) IndicesExistsRequest(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 64 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class IndicesTest method testAliasExists.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testAliasExists() throws Exception {
    assertThat(indices.aliasExists("graylog_alias")).isFalse();
    final IndicesAdminClient adminClient = client.admin().indices();
    final IndicesAliasesRequest request = adminClient.prepareAliases().addAlias(INDEX_NAME, "graylog_alias").request();
    final IndicesAliasesResponse response = adminClient.aliases(request).actionGet(ES_TIMEOUT);
    assertThat(response.isAcknowledged()).isTrue();
    assertThat(indices.aliasExists("graylog_alias")).isTrue();
}
Also used : IndicesAliasesRequest(org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient) IndicesAliasesResponse(org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 65 with UsingDataSet

use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.

the class IndicesTest method indexCreationDateReturnsNullForNonExistingIndex.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void indexCreationDateReturnsNullForNonExistingIndex() {
    final DateTime indexCreationDate = indices.indexCreationDate("index_missing");
    assertThat(indexCreationDate).isNull();
}
Also used : ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Aggregations

UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)94 Test (org.junit.Test)94 DateTime (org.joda.time.DateTime)40 DBCollection (com.mongodb.DBCollection)29 ZonedDateTime (java.time.ZonedDateTime)19 DBObject (com.mongodb.DBObject)15 BasicDBObjectBuilder (com.mongodb.BasicDBObjectBuilder)13 ObjectId (org.bson.types.ObjectId)9 MongoDBServiceTest (org.graylog2.database.MongoDBServiceTest)9 Timer (com.codahale.metrics.Timer)6 Histogram (com.codahale.metrics.Histogram)5 JsonPath (com.jayway.restassured.path.json.JsonPath)5 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)5 HistogramResult (org.graylog2.indexer.results.HistogramResult)5 AbsoluteRange (org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange)5 List (java.util.List)4 TermsResult (org.graylog2.indexer.results.TermsResult)4 User (org.graylog2.plugin.database.users.User)4 LdapSettings (org.graylog2.shared.security.ldap.LdapSettings)4 Map (java.util.Map)3