Search in sources :

Example 86 with UsingDataSet

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

the class ClusterConfigServiceImplTest method getReturnsNullOnNonExistingConfig.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getReturnsNullOnNonExistingConfig() throws Exception {
    final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
    assertThat(collection.count()).isEqualTo(0L);
    assertThat(clusterConfigService.get(CustomConfig.class)).isNull();
}
Also used : DBCollection(com.mongodb.DBCollection) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 87 with UsingDataSet

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

the class DashboardServiceImplTest method testCreate.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void testCreate() throws Exception {
    final String title = "Dashboard Title";
    final String description = "This is the dashboard description";
    final String creatorUserId = "foobar";
    final DateTime createdAt = Tools.nowUTC();
    final Dashboard dashboard = dashboardService.create(title, description, creatorUserId, createdAt);
    assertNotNull(dashboard);
    assertEquals(title, dashboard.getTitle());
    assertEquals(description, dashboard.getDescription());
    assertNotNull(dashboard.getId());
    assertEquals(0, dashboardService.count());
}
Also used : DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 88 with UsingDataSet

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

the class LdapSettingsServiceImplTest method loadReturnsNullIfDatabaseHasMoreThanOneEntry.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void loadReturnsNullIfDatabaseHasMoreThanOneEntry() throws Exception {
    final DBCollection collection = mongoRule.getMongoConnection().getDatabase().getCollection("ldap_settings");
    collection.insert(new BasicDBObject("foo", "bar"), new BasicDBObject("quux", "baz"));
    assertThat(ldapSettingsService.load()).isNull();
}
Also used : DBCollection(com.mongodb.DBCollection) BasicDBObject(com.mongodb.BasicDBObject) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 89 with UsingDataSet

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

the class LdapSettingsServiceImplTest method loadReturnsLdapSettings.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void loadReturnsLdapSettings() throws Exception {
    final LdapSettings ldapSettings = ldapSettingsService.load();
    assertThat(ldapSettings).isNotNull();
    assertThat(ldapSettings.getId()).isEqualTo("54e3deadbeefdeadbeefaffe");
    assertThat(ldapSettings.getUri()).isEqualTo(URI.create("ldap://localhost:389"));
    assertThat(ldapSettings.getSystemPassword()).isEqualTo("password");
}
Also used : LdapSettings(org.graylog2.shared.security.ldap.LdapSettings) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 90 with UsingDataSet

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

the class LdapSettingsServiceImplTest method deleteRemovesAllLdapSettings.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void deleteRemovesAllLdapSettings() throws Exception {
    final DBCollection collection = mongoRule.getMongoConnection().getDatabase().getCollection("ldap_settings");
    assertThat(collection.count()).isEqualTo(1L);
    ldapSettingsService.delete();
    assertThat(collection.count()).isEqualTo(0);
}
Also used : DBCollection(com.mongodb.DBCollection) 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