use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method listReturnsAllClasses.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void listReturnsAllClasses() throws Exception {
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
collection.save(new BasicDBObjectBuilder().add("type", CustomConfig.class.getCanonicalName()).add("payload", Collections.singletonMap("text", "TEST")).add("last_updated", TIME.toString()).add("last_updated_by", "ID").get());
collection.save(new BasicDBObjectBuilder().add("type", AnotherCustomConfig.class.getCanonicalName()).add("payload", Collections.singletonMap("text", "TEST")).add("last_updated", TIME.toString()).add("last_updated_by", "ID").get());
assertThat(collection.count()).isEqualTo(2L);
assertThat(clusterConfigService.list()).hasSize(2).containsOnly(CustomConfig.class, AnotherCustomConfig.class);
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method getReturnsExistingConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getReturnsExistingConfig() throws Exception {
DBObject dbObject = new BasicDBObjectBuilder().add("type", CustomConfig.class.getCanonicalName()).add("payload", Collections.singletonMap("text", "TEST")).add("last_updated", TIME.toString()).add("last_updated_by", "ID").get();
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
collection.save(dbObject);
assertThat(collection.count()).isEqualTo(1L);
CustomConfig customConfig = clusterConfigService.get(CustomConfig.class);
assertThat(customConfig.text).isEqualTo("TEST");
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class NodeServiceImplTest method testRegisterServerWithExistingNode.
@Test
@UsingDataSet(locations = "NodeServiceImplTest-one-node.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testRegisterServerWithExistingNode() throws Exception {
final Node node1 = nodeService.byNodeId(nodeId);
assertThat(node1.getNodeId()).describedAs("There should be one existing node").isEqualTo(NODE_ID);
nodeService.registerServer(nodeId.toString(), true, TRANSPORT_URI, LOCAL_CANONICAL_HOSTNAME);
final DBCollection collection = mongoRule.getMongoConnection().getDatabase().getCollection("nodes");
assertThat(collection.count()).describedAs("There should only be one node").isEqualTo(1);
final Node node2 = nodeService.byNodeId(nodeId);
assertThat(node2).isNotNull();
assertThat(node2.getHostname()).isEqualTo(LOCAL_CANONICAL_HOSTNAME);
assertThat(node2.getTransportAddress()).isEqualTo(TRANSPORT_URI.toString());
assertThat(node2.isMaster()).isTrue();
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class LdapSettingsServiceImplTest method loadReturnNullIfPasswordSecretIsWrong.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT, locations = "LdapSettingsServiceImplTest-invalid-password.json")
public void loadReturnNullIfPasswordSecretIsWrong() throws Exception {
final LdapSettings ldapSettings = ldapSettingsService.load();
assertThat(ldapSettings).isNull();
}
use of com.lordofthejars.nosqlunit.annotation.UsingDataSet in project graylog2-server by Graylog2.
the class ClusterConfigServiceImplTest method getWithKeyReturnsNullOnNonExistingConfig.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void getWithKeyReturnsNullOnNonExistingConfig() throws Exception {
final DBCollection collection = mongoConnection.getDatabase().getCollection(COLLECTION_NAME);
assertThat(collection.count()).isEqualTo(0L);
assertThat(clusterConfigService.get("foo", CustomConfig.class)).isNull();
}
Aggregations