use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class EventDefinitionFacadeTest method resolveNativeEntity.
@Test
@MongoDBFixtures("EventDefinitionFacadeTest.json")
public void resolveNativeEntity() {
EntityDescriptor eventDescriptor = EntityDescriptor.create("5d4032513d2746703d1467f6", ModelTypes.EVENT_DEFINITION_V1);
EntityDescriptor streamDescriptor = EntityDescriptor.create("5cdab2293d27467fbe9e8a72", ModelTypes.STREAM_V1);
Set<EntityDescriptor> expectedNodes = ImmutableSet.of(eventDescriptor, streamDescriptor);
Graph<EntityDescriptor> graph = facade.resolveNativeEntity(eventDescriptor);
assertThat(graph).isNotNull();
Set<EntityDescriptor> nodes = graph.nodes();
assertThat(nodes).isEqualTo(expectedNodes);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class EventDefinitionFacadeTest method resolveForInstallation.
@Test
@MongoDBFixtures("EventDefinitionFacadeTest.json")
public void resolveForInstallation() {
EntityV1 eventEntityV1 = createTestEntity();
final NotificationEntity notificationEntity = NotificationEntity.builder().title(ValueReference.of("title")).description(ValueReference.of("description")).config(HttpEventNotificationConfigEntity.builder().url(ValueReference.of("http://url")).build()).build();
final JsonNode data = objectMapper.convertValue(notificationEntity, JsonNode.class);
final EntityV1 notificationV1 = EntityV1.builder().data(data).id(ModelId.of("123123")).type(ModelTypes.EVENT_DEFINITION_V1).build();
final EntityDescriptor entityDescriptor = EntityDescriptor.create("123123", ModelTypes.NOTIFICATION_V1);
Map<String, ValueReference> parameters = ImmutableMap.of();
Map<EntityDescriptor, Entity> entities = ImmutableMap.of(entityDescriptor, notificationV1);
Graph<Entity> graph = facade.resolveForInstallation(eventEntityV1, parameters, entities);
assertThat(graph).isNotNull();
Set<Entity> expectedNodes = ImmutableSet.of(eventEntityV1, notificationV1);
assertThat(graph.nodes()).isEqualTo(expectedNodes);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class AggregationEventProcessorConfigTest method toJobSchedulerConfig.
@Test
@MongoDBFixtures("aggregation-processors.json")
public void toJobSchedulerConfig() {
final EventDefinitionDto dto = dbService.get("54e3deadbeefdeadbeefaffe").orElse(null);
assertThat(dto).isNotNull();
assertThat(dto.config().toJobSchedulerConfig(dto, clock)).isPresent().get().satisfies(schedulerConfig -> {
assertThat(schedulerConfig.jobDefinitionConfig()).satisfies(jobDefinitionConfig -> {
assertThat(jobDefinitionConfig).isInstanceOf(EventProcessorExecutionJob.Config.class);
final EventProcessorExecutionJob.Config config = (EventProcessorExecutionJob.Config) jobDefinitionConfig;
assertThat(config.eventDefinitionId()).isEqualTo(dto.id());
assertThat(config.processingWindowSize()).isEqualTo(300000);
assertThat(config.processingHopSize()).isEqualTo(300000);
assertThat(config.parameters()).isEqualTo(AggregationEventProcessorParameters.builder().timerange(AbsoluteRange.create(clock.nowUTC().minus(300000), clock.nowUTC())).build());
});
assertThat(schedulerConfig.schedule()).satisfies(schedule -> {
assertThat(schedule).isInstanceOf(IntervalJobSchedule.class);
final IntervalJobSchedule config = (IntervalJobSchedule) schedule;
assertThat(config.interval()).isEqualTo(300000);
assertThat(config.unit()).isEqualTo(TimeUnit.MILLISECONDS);
});
});
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class AlarmCallbackConfigurationServiceImplTest method testGetForStreamSingleDocument.
@Test
@MongoDBFixtures("alarmCallbackConfigurationsSingleDocument.json")
public void testGetForStreamSingleDocument() throws Exception {
final Stream stream = mock(StreamImpl.class);
final String streamId = "5400deadbeefdeadbeefaffe";
when(stream.getId()).thenReturn(streamId);
final List<AlarmCallbackConfiguration> configs = alarmCallbackConfigurationService.getForStream(stream);
final AlarmCallbackConfiguration alarmCallback = configs.get(0);
assertNotNull("Returned list should not be null", configs);
assertEquals("Returned list should contain a single document", 1, configs.size());
assertNotNull("Returned Alarm Callback should not be null", alarmCallback);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class AlertServiceImplTest method loadRecentOfStreamQueriesByDate.
@Test
@MongoDBFixtures("multiple-alerts.json")
public void loadRecentOfStreamQueriesByDate() throws Exception {
final List<Alert> alerts = alertService.loadRecentOfStream(STREAM_ID, new DateTime(0L, DateTimeZone.UTC), 300);
assertThat(alerts.size()).isEqualTo(2);
}
Aggregations