use of org.graylog.events.JobSchedulerTestClock in project graylog2-server by Graylog2.
the class AggregationEventProcessorConfigTest method setUp.
@Before
public void setUp() throws Exception {
final ObjectMapper objectMapper = new ObjectMapperProvider().get();
objectMapper.registerSubtypes(new NamedType(AggregationEventProcessorConfig.class, AggregationEventProcessorConfig.TYPE_NAME));
objectMapper.registerSubtypes(new NamedType(TemplateFieldValueProvider.Config.class, TemplateFieldValueProvider.Config.TYPE_NAME));
objectMapper.registerSubtypes(new NamedType(PersistToStreamsStorageHandler.Config.class, PersistToStreamsStorageHandler.Config.TYPE_NAME));
final MongoJackObjectMapperProvider mapperProvider = new MongoJackObjectMapperProvider(objectMapper);
this.dbService = new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, stateService, mock(EntityOwnershipService.class));
this.clock = new JobSchedulerTestClock(DateTime.now(DateTimeZone.UTC));
}
use of org.graylog.events.JobSchedulerTestClock in project graylog2-server by Graylog2.
the class DBProcessingStatusServiceTest method setUp.
@Before
public void setUp() throws Exception {
when(nodeId.toString()).thenReturn(NODE_ID);
final ObjectMapper objectMapper = new ObjectMapperProvider().get();
final MongoJackObjectMapperProvider mapperProvider = new MongoJackObjectMapperProvider(objectMapper);
clock = spy(new JobSchedulerTestClock(DateTime.parse("2019-01-01T00:00:00.000Z")));
updateThreshold = spy(Duration.minutes(1));
dbService = new DBProcessingStatusService(mongodb.mongoConnection(), nodeId, clock, updateThreshold, 1, mapperProvider, baseConfiguration);
db = JacksonDBCollection.wrap(mongodb.mongoConnection().getDatabase().getCollection(DBProcessingStatusService.COLLECTION_NAME), ProcessingStatusDto.class, ObjectId.class, mapperProvider.get());
}
use of org.graylog.events.JobSchedulerTestClock in project graylog2-server by Graylog2.
the class EventProcessorExecutionJobTest method setUp.
@Before
public void setUp() {
clock = new JobSchedulerTestClock(DateTime.parse("2019-01-01T00:00:00.000Z"));
jobScheduleStrategies = new JobScheduleStrategies(clock);
when(eventsConfigurationProvider.get()).thenReturn(EventsConfiguration.builder().build());
}
use of org.graylog.events.JobSchedulerTestClock in project graylog2-server by Graylog2.
the class JobTriggerUpdatesTest method setUp.
@Before
public void setUp() throws Exception {
this.clock = new JobSchedulerTestClock(DateTime.now(DateTimeZone.UTC));
this.strategies = new JobScheduleStrategies(clock);
}
use of org.graylog.events.JobSchedulerTestClock in project graylog2-server by Graylog2.
the class CreateJobTriggerRequestTest method toDto.
@Test
public void toDto() {
final DateTime now = DateTime.now(UTC);
final JobSchedulerTestClock clock = new JobSchedulerTestClock(now);
final IntervalJobSchedule schedule = IntervalJobSchedule.builder().interval(1).unit(TimeUnit.SECONDS).build();
final CreateJobTriggerRequest request = CreateJobTriggerRequest.builder().jobDefinitionId("abc-123").startTime(now).nextTime(now).schedule(schedule).build();
final JobTriggerData.FallbackData data = new JobTriggerData.FallbackData();
final CreateJobTriggerRequest requestWithDataAndEndTime = CreateJobTriggerRequest.builder().jobDefinitionId("abc-123").startTime(now).endTime(now.plusDays(1)).nextTime(now).schedule(schedule).data(data).build();
assertThat(request.toDto(clock)).satisfies(dto -> {
assertThat(dto.jobDefinitionId()).isEqualTo("abc-123");
assertThat(dto.startTime()).isEqualTo(now);
assertThat(dto.endTime()).isNotPresent();
assertThat(dto.nextTime()).isEqualTo(now);
assertThat(dto.createdAt()).isEqualTo(now);
assertThat(dto.updatedAt()).isEqualTo(now);
assertThat(dto.triggeredAt()).isNotPresent();
assertThat(dto.status()).isEqualTo(JobTriggerStatus.RUNNABLE);
assertThat(dto.lock()).isEqualTo(JobTriggerLock.empty());
assertThat(dto.schedule()).isEqualTo(schedule);
assertThat(dto.data()).isNotPresent();
});
assertThat(requestWithDataAndEndTime.toDto(clock)).satisfies(dto -> {
assertThat(dto.jobDefinitionId()).isEqualTo("abc-123");
assertThat(dto.startTime()).isEqualTo(now);
assertThat(dto.endTime()).isPresent().get().isEqualTo(now.plusDays(1));
assertThat(dto.nextTime()).isEqualTo(now);
assertThat(dto.createdAt()).isEqualTo(now);
assertThat(dto.updatedAt()).isEqualTo(now);
assertThat(dto.triggeredAt()).isNotPresent();
assertThat(dto.status()).isEqualTo(JobTriggerStatus.RUNNABLE);
assertThat(dto.lock()).isEqualTo(JobTriggerLock.empty());
assertThat(dto.schedule()).isEqualTo(schedule);
assertThat(dto.data()).isPresent().get().isEqualTo(data);
});
}
Aggregations