@Test public void charting() { // set up data long platformId = 1L; long methodId = 3L; long sensorTypeId = 11L; Object object = mock(Object.class); Object[] parameters = new Object[2]; Object result = mock(Object.class); Double firstTimerValue = 1000.453d; Double secondTimerValue = 1323.675d; when(timer.getCurrentTime()).thenReturn(firstTimerValue).thenReturn(secondTimerValue); when(platformManager.getPlatformId()).thenReturn(platformId); when(registeredSensorConfig.getSettings()).thenReturn(Collections.<String, Object> singletonMap("charting", Boolean.TRUE)); timerHook.beforeBody(methodId, sensorTypeId, object, parameters, registeredSensorConfig); timerHook.firstAfterBody(methodId, sensorTypeId, object, parameters, result, false, registeredSensorConfig); timerHook.secondAfterBody(coreService, methodId, sensorTypeId, object, parameters, result, false, registeredSensorConfig); ArgumentCaptor<TimerData> captor = ArgumentCaptor.forClass(TimerData.class); verify(coreService).addDefaultData(captor.capture()); TimerData timerData = captor.getValue(); assertThat(timerData.isCharting(), is(true)); }
@Test public void oneRecordThatIsHttpCharting() { Double firstTimerValue = 1000.453d; Double secondTimerValue = 1323.675d; Long firstCpuTimerValue = 5000L; Long secondCpuTimerValue = 6872L; HttpTimerData data = new HttpTimerData(null, platformId, sensorTypeId, methodId); data.setCharting(true); when(timer.getCurrentTime()).thenReturn(firstTimerValue).thenReturn(secondTimerValue); when(threadMXBean.getCurrentThreadCpuTime()).thenReturn(firstCpuTimerValue).thenReturn(secondCpuTimerValue); when(platformManager.getPlatformId()).thenReturn(platformId); when(registeredSensorConfig.getSettings()).thenReturn(Collections.<String, Object> singletonMap("charting", Boolean.TRUE)); Object[] parameters = new Object[] { httpServletRequest, httpServletResponse }; httpHook.beforeBody(methodId, sensorTypeId, servlet, parameters, registeredSensorConfig); httpHook.firstAfterBody(methodId, sensorTypeId, servlet, parameters, result, false, registeredSensorConfig); httpHook.secondAfterBody(coreService, methodId, sensorTypeId, servlet, parameters, result, false, registeredSensorConfig); verify(coreService).addDefaultData(Matchers.argThat(new HttpTimerDataVerifier(data))); verifyZeroInteractions(result); }
timerData.calculateCpuMin(cpuDuration); boolean charting = Boolean.TRUE.equals(rsc.getSettings().get("charting")); timerData.setCharting(charting);
when(platformManager.getPlatformId()).thenReturn(platformId); when(registeredSensorConfig.getSettings()).thenReturn(Collections.<String, Object> singletonMap("charting", Boolean.TRUE)); verify(platformManager).getPlatformId(); verify(registeredSensorConfig).isPropertyAccess(); verify(registeredSensorConfig).getSettings();
assertThat(rscCaptor.getValue().getReturnType(), is(methodInstrumentationConfig.getReturnType())); assertThat(rscCaptor.getValue().isStartsInvocation(), is(sensorInstrumentationPoint.isStartsInvocation())); assertThat(rscCaptor.getValue().getSettings(), is(sensorInstrumentationPoint.getSettings())); assertThat(rscCaptor.getValue().getPropertyAccessorList(), is(sensorInstrumentationPoint.getPropertyAccessorList())); verifyNoMoreInteractions(hookDispatcherMapper, connection, classHashHelper);
assertThat(rscCaptor.getValue().getReturnType(), is(methodInstrumentationConfig.getReturnType())); assertThat(rscCaptor.getValue().isStartsInvocation(), is(sensorInstrumentationPoint.isStartsInvocation())); assertThat(rscCaptor.getValue().getSettings(), is(sensorInstrumentationPoint.getSettings())); assertThat(rscCaptor.getValue().getPropertyAccessorList(), is(sensorInstrumentationPoint.getPropertyAccessorList())); verifyNoMoreInteractions(hookDispatcherMapper, connection, classHashHelper);
assertThat(rscCaptor.getValue().getReturnType(), is(methodInstrumentationConfig.getReturnType())); assertThat(rscCaptor.getValue().isStartsInvocation(), is(sensorInstrumentationPoint.isStartsInvocation())); assertThat(rscCaptor.getValue().getSettings(), is(sensorInstrumentationPoint.getSettings())); assertThat(rscCaptor.getValue().getPropertyAccessorList(), is(sensorInstrumentationPoint.getPropertyAccessorList())); verifyNoMoreInteractions(hookDispatcherMapper, connection, classHashHelper);
assertThat(rscCaptor.getValue().getReturnType(), is(methodInstrumentationConfig.getReturnType())); assertThat(rscCaptor.getValue().isStartsInvocation(), is(sensorInstrumentationPoint.isStartsInvocation())); assertThat(rscCaptor.getValue().getSettings(), is(sensorInstrumentationPoint.getSettings())); assertThat(rscCaptor.getValue().getPropertyAccessorList(), is(sensorInstrumentationPoint.getPropertyAccessorList())); ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
Map<String, Object> map = new HashMap<String, Object>(); map.put("minduration", minDuration); when(rsc.getSettings()).thenReturn(map); when(rsc.getMethodSensors()).thenReturn(Collections.singletonList(methodSensor)); when(methodSensor.getSensorTypeConfig()).thenReturn(methodSensorTypeConfig);
assertThat(rscCaptor.getValue().getReturnType(), is(methodInstrumentationConfig.getReturnType())); assertThat(rscCaptor.getValue().isStartsInvocation(), is(sensorInstrumentationPoint.isStartsInvocation())); assertThat(rscCaptor.getValue().getSettings(), is(sensorInstrumentationPoint.getSettings())); assertThat(rscCaptor.getValue().getPropertyAccessorList(), is(sensorInstrumentationPoint.getPropertyAccessorList())); verifyNoMoreInteractions(hookDispatcherMapper, connection, classHashHelper);
when(registeredSensorConfig.getSettings()).thenReturn(Collections.<String, Object> singletonMap("charting", Boolean.TRUE)); verify(registeredSensorConfig, times(2)).getSettings(); verify(platformManager, times(2)).getPlatformId(); verify(coreService, times(2)).addDefaultData(captor.capture());
} else { if (rsc.getSettings().containsKey("minduration")) { Long minDuration = (Long) rsc.getSettings().get("minduration"); minDurationMap.put(invocationStartId.get(), minDuration.doubleValue()); checkForSavingOrNot(coreService, rsc, invocationSequenceData, startTime, endTime, duration);
boolean charting = Boolean.TRUE.equals(rsc.getSettings().get("charting")); data.setCharting(charting);