@Test public void propertyAccessException() { // 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.isPropertyAccess()).thenReturn(true); timerHook.beforeBody(methodId, sensorTypeId, object, parameters, registeredSensorConfig); timerHook.firstAfterBody(methodId, sensorTypeId, object, parameters, result, true, registeredSensorConfig); timerHook.secondAfterBody(coreService, methodId, sensorTypeId, object, parameters, result, true, registeredSensorConfig); verify(registeredSensorConfig, times(1)).isPropertyAccess(); verify(propertyAccessor, times(1)).getParameterContentData(registeredSensorConfig.getPropertyAccessorList(), object, parameters, result, true); }
@Test public void propertyAccess() { // 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(rsc.isPropertyAccess()).thenReturn(true); invocationSequenceHook.beforeBody(methodId, sensorTypeId, object, parameters, rsc); invocationSequenceHook.firstAfterBody(methodId, sensorTypeId, object, parameters, result, false, rsc); invocationSequenceHook.secondAfterBody(coreService, methodId, sensorTypeId, object, parameters, result, false, rsc); verify(rsc, times(1)).isPropertyAccess(); verify(propertyAccessor, times(1)).getParameterContentData(rsc.getPropertyAccessorList(), object, parameters, result, false); }
@Test public void propertyAccessException() { // 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(rsc.isPropertyAccess()).thenReturn(true); invocationSequenceHook.beforeBody(methodId, sensorTypeId, object, parameters, rsc); invocationSequenceHook.firstAfterBody(methodId, sensorTypeId, object, parameters, result, true, rsc); invocationSequenceHook.secondAfterBody(coreService, methodId, sensorTypeId, object, parameters, result, true, rsc); verify(rsc, times(1)).isPropertyAccess(); verify(propertyAccessor, times(1)).getParameterContentData(rsc.getPropertyAccessorList(), object, parameters, result, true); }
@Test public void propertyAccess() { // 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; ParameterContentData parameterContentData = Mockito.mock(ParameterContentData.class); when(timer.getCurrentTime()).thenReturn(firstTimerValue).thenReturn(secondTimerValue); when(platformManager.getPlatformId()).thenReturn(platformId); when(registeredSensorConfig.isPropertyAccess()).thenReturn(true); when(propertyAccessor.getParameterContentData(registeredSensorConfig.getPropertyAccessorList(), object, parameters, result, false)).thenReturn(Collections.singletonList(parameterContentData)); 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); verify(registeredSensorConfig, times(1)).isPropertyAccess(); verify(propertyAccessor, times(1)).getParameterContentData(registeredSensorConfig.getPropertyAccessorList(), object, parameters, result, false); ArgumentCaptor<TimerData> captor = ArgumentCaptor.forClass(TimerData.class); verify(coreService).addDefaultData(captor.capture()); TimerData timerData = captor.getValue(); assertThat(timerData.getParameterContentData(), hasSize(1)); assertThat(timerData.getParameterContentData(), hasItem(parameterContentData)); }
parameterContentData = propertyAccessor.getParameterContentData(rsc.getPropertyAccessorList(), object, parameters, result, exception);
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().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().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); verify(connection, times(1)).isConnected();
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().isStartsInvocation(), is(sensorInstrumentationPoint.isStartsInvocation())); assertThat(rscCaptor.getValue().getSettings(), is(sensorInstrumentationPoint.getSettings())); assertThat(rscCaptor.getValue().getPropertyAccessorList(), is(sensorInstrumentationPoint.getPropertyAccessorList())); verifyNoMoreInteractions(hookDispatcherMapper, connection, classHashHelper);
List<ParameterContentData> parameterContentData = propertyAccessor.getParameterContentData(rsc.getPropertyAccessorList(), object, parameters, result, exception);