use of com.google.recaptchaenterprise.v1.Event in project skywalking by apache.
the class EventHookCallbackTest method testEventCallbackHasRightFlow.
@Test
public void testEventCallbackHasRightFlow() throws Exception {
List<AlarmMessage> msgs = mockAlarmMessagesHasSingleElement();
EventHookCallback callback = new EventHookCallback(this.moduleManager);
when(moduleManager.find("event-analyzer")).thenReturn(moduleProviderHolder);
when(moduleProviderHolder.provider()).thenReturn(moduleServiceHolder);
when(moduleServiceHolder.getService(EventAnalyzerService.class)).thenReturn(mockEventAnalyzerService);
// make sure current service be called.
callback.doAlarm(msgs);
verify(mockEventAnalyzerService).analyze(any(Event.class));
when(moduleServiceHolder.getService(EventAnalyzerService.class)).thenReturn(eventAnalyzerService);
callback.doAlarm(msgs);
// Ensure that the current Event is properly constructed
ArgumentCaptor<Event> argument = ArgumentCaptor.forClass(Event.class);
verify(eventAnalyzerService).analyze(argument.capture());
Event value = argument.getValue();
AlarmMessage msg = msgs.get(0);
assertEquals(msg.getName(), value.getSource().getService());
assertEquals("Alarm", value.getName());
assertEquals(msg.getAlarmMessage(), value.getMessage());
assertEquals(msg.getPeriod(), (value.getEndTime() - value.getStartTime()) / 1000 / 60);
}
use of com.google.recaptchaenterprise.v1.Event in project skywalking by apache.
the class EventHookCallbackTest method testRelationEventBeProperlyConstructed.
@Test
public void testRelationEventBeProperlyConstructed() {
List<AlarmMessage> msgs = mockAlarmMessagesHasSourceAndDest();
EventHookCallback callback = new EventHookCallback(this.moduleManager);
when(moduleManager.find("event-analyzer")).thenReturn(moduleProviderHolder);
when(moduleProviderHolder.provider()).thenReturn(moduleServiceHolder);
when(moduleServiceHolder.getService(EventAnalyzerService.class)).thenReturn(eventAnalyzerService);
callback.doAlarm(msgs);
ArgumentCaptor<Event> argument = ArgumentCaptor.forClass(Event.class);
verify(eventAnalyzerService, times(2)).analyze(argument.capture());
List<Event> events = argument.getAllValues();
assertEquals(events.size(), 2);
Event sourceEvent = events.get(0);
Event destEvent = events.get(1);
AlarmMessage msg = msgs.get(0);
assertEquals(sourceEvent.getSource().getService(), IDManager.ServiceID.analysisId(msg.getId0()).getName());
assertEquals((sourceEvent.getEndTime() - sourceEvent.getStartTime()) / 1000 / 60, msg.getPeriod());
assertEquals(destEvent.getSource().getService(), IDManager.ServiceID.analysisId(msg.getId1()).getName());
assertEquals((destEvent.getEndTime() - destEvent.getStartTime()) / 1000 / 60, msg.getPeriod());
}
use of com.google.recaptchaenterprise.v1.Event in project incubator-skywalking by apache.
the class EventHookCallback method doAlarm.
@Override
public void doAlarm(List<AlarmMessage> alarmMessage) {
EventAnalyzerService analyzerService = manager.find(EventAnalyzerModule.NAME).provider().getService(EventAnalyzerService.class);
alarmMessage.forEach(a -> {
for (Event event : constructCurrentEvent(a)) {
analyzerService.analyze(event);
}
});
}
use of com.google.recaptchaenterprise.v1.Event in project prison-api by ministryofjustice.
the class NomisApiV1ServiceTest method getEvents.
@Test
public void getEvents() {
final var date = LocalDateTime.parse("2020-01-02T03:02:01");
when(eventsV1Repository.getEvents(anyString(), isNull(), anyLong(), isNull(), anyString(), any(), anyLong())).thenReturn(List.of(new EventSP(5L, date, "MDI", "A1234", "ETYPE", "Event ", "Data 2", " and 3")));
final var events = service.getEvents("prison", new OffenderIdentifier("12345"), "type", LocalDateTime.now(), 5L);
assertThat(events).containsExactly(new Event("ETYPE", 5L, "A1234", "MDI", date, "Event Data 2 and 3"));
}
use of com.google.recaptchaenterprise.v1.Event in project kubernetes-client by fabric8io.
the class V1beta1EventsTest method testGet.
@Test
void testGet() {
// Given
server.expect().get().withPath("/apis/events.k8s.io/v1beta1/namespaces/default/events/event1").andReturn(HttpURLConnection.HTTP_OK, new EventBuilder().withNewMetadata().withName("event1").endMetadata().build()).once();
// When
Event e1 = client.events().v1beta1().events().inNamespace("default").withName("event1").get();
// Then
assertThat(e1).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "event1");
}
Aggregations