use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20191203120602_MigrateSavedSearchesToViewsTest method migrateSavedSearchRelativeWithIntervalField.
@Test
@MongoDBFixtures("sample_saved_search_relative_with_interval_field.json")
public void migrateSavedSearchRelativeWithIntervalField() throws Exception {
this.migration.upgrade();
final MigrationCompleted migrationCompleted = captureMigrationCompleted();
assertThat(migrationCompleted.savedSearchIds()).containsExactly(new AbstractMap.SimpleEntry<>("5c7e5499f38ed7e1d8d6a613", "5de0e98900002a0017000002"));
assertViewServiceCreatedViews(1, resourceFile("sample_saved_search_relative_with_interval_field-expected_views.json"));
assertSearchServiceCreated(1, resourceFile("sample_saved_search_relative_with_interval_field-expected_searches.json"));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20191203120602_MigrateSavedSearchesToViewsTest method migrateSavedSearchWithRelativeTimerange.
@Test
@MongoDBFixtures("sample_saved_search_relative.json")
public void migrateSavedSearchWithRelativeTimerange() throws Exception {
this.migration.upgrade();
final MigrationCompleted migrationCompleted = captureMigrationCompleted();
assertThat(migrationCompleted.savedSearchIds()).containsExactly(new AbstractMap.SimpleEntry<>("5c7e5499f38ed7e1d8d6a613", "5de0e98900002a0017000002"));
assertViewServiceCreatedViews(1, resourceFile("sample_saved_search_relative-expected_views.json"));
assertSearchServiceCreated(1, resourceFile("sample_saved_search_relative-expected_searches.json"));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20191203120602_MigrateSavedSearchesToViewsTest method migrateSavedSearchWithMissingFields.
@Test
@MongoDBFixtures("sample_saved_search_with_missing_fields.json")
public void migrateSavedSearchWithMissingFields() throws Exception {
this.migration.upgrade();
final MigrationCompleted migrationCompleted = captureMigrationCompleted();
assertThat(migrationCompleted.savedSearchIds()).containsExactly(new AbstractMap.SimpleEntry<>("5de660b7b2d44b5813c1d7f6", "5de0e98900002a0017000002"));
assertViewServiceCreatedViews(1, resourceFile("sample_saved_search_with_missing_fields-expected_views.json"));
assertSearchServiceCreated(1, resourceFile("sample_saved_search_with_missing_fields-expected_searches.json"));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20191203120602_MigrateSavedSearchesToViewsTest method migrateSavedSearchWithoutMessageRow.
@Test
@MongoDBFixtures("sample_saved_search_without_message_row.json")
public void migrateSavedSearchWithoutMessageRow() throws Exception {
this.migration.upgrade();
final MigrationCompleted migrationCompleted = captureMigrationCompleted();
assertThat(migrationCompleted.savedSearchIds()).containsExactly(new AbstractMap.SimpleEntry<>("5c7e5499f38ed7e1d8d6a613", "5de0e98900002a0017000002"));
assertViewServiceCreatedViews(1, resourceFile("sample_saved_search_without_message_row-expected_views.json"));
assertSearchServiceCreated(1, resourceFile("sample_saved_search_without_message_row-expected_searches.json"));
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class V20190127111728_MigrateWidgetFormatSettingsTest method testMigrationWithOneChartColorMapping.
@Test
@MongoDBFixtures("V20190127111728_MigrateWidgetFormatSettings.json")
public void testMigrationWithOneChartColorMapping() {
final BasicDBObject dbQuery1 = new BasicDBObject();
dbQuery1.put("_id", new ObjectId("5e2ee372b22d7970576b2eb3"));
final MongoCollection<Document> collection = mongoDB.mongoConnection().getMongoDatabase().getCollection("views");
migration.upgrade();
final FindIterable<Document> views = collection.find(dbQuery1);
final Document view1 = views.first();
@SuppressWarnings("unchecked") final List<Document> widgets1 = (List) view1.get("state", Document.class).get("2c67cc0f-c62e-47c1-8b70-e3198925e6bc", Document.class).get("widgets");
assertThat(widgets1.size()).isEqualTo(2);
Set<Document> aggregationWidgets = widgets1.stream().filter(w -> w.getString("type").equals("aggregation")).collect(Collectors.toSet());
assertThat(aggregationWidgets.size()).isEqualTo(1);
final Document aggregationWidget = aggregationWidgets.iterator().next();
final Document config = aggregationWidget.get("config", Document.class);
final Document formattingSettings = config.get("formatting_settings", Document.class);
@SuppressWarnings("unchecked") final List<Document> chartColors = (List) formattingSettings.get("chart_colors", List.class);
assertThat(chartColors.size()).isEqualTo(1);
final Document chartColor = chartColors.get(0);
assertThat(chartColor.getString("field_name")).isEqualTo("count()");
assertThat(chartColor.getString("chart_color")).isEqualTo("#e91e63");
}
Aggregations