/** * {@inheritDoc} */ @Override protected Void performRemoteCall(IAgentService remoteObject) throws Exception { remoteObject.instrumentationApplied(platformIdent, methodToSensorMap); return null; }
@Test public void instrumentationApplied() throws Exception { when(client.isConnected()).thenReturn(true); Map<Long, long[]> methodToSensorMap = mock(Map.class); when(methodToSensorMap.isEmpty()).thenReturn(false); long id = 7; connection.instrumentationApplied(id, methodToSensorMap); verify(agentService, times(1)).instrumentationApplied(id, methodToSensorMap); verifyNoMoreInteractions(agentService); }
@Test(expectedExceptions = { ServerUnavailableException.class }) public void timeout() throws Exception { when(client.isConnected()).thenReturn(true); doThrow(TimeoutException.class).when(agentService).instrumentationApplied(anyLong(), Matchers.<Map<Long, long[]>> any()); Map<Long, long[]> methodToSensorMap = mock(Map.class); when(methodToSensorMap.isEmpty()).thenReturn(false); long id = 7; try { connection.instrumentationApplied(id, methodToSensorMap); } catch (ServerUnavailableException e) { assertThat(e.isServerTimeout(), is(true)); throw e; } finally { verify(agentService, times(1)).instrumentationApplied(id, methodToSensorMap); verifyNoMoreInteractions(agentService); } }
@Test(expectedExceptions = { ServerUnavailableException.class }) public void remoteException() throws Exception { when(client.isConnected()).thenReturn(true); doThrow(RuntimeException.class).when(agentService).instrumentationApplied(anyLong(), Matchers.<Map<Long, long[]>> any()); Map<Long, long[]> methodToSensorMap = mock(Map.class); when(methodToSensorMap.isEmpty()).thenReturn(false); long id = 7; try { connection.instrumentationApplied(id, methodToSensorMap); } catch (ServerUnavailableException e) { assertThat(e.isServerTimeout(), is(false)); throw e; } finally { // call depends on the retry strategy verify(agentService, times(RetryStrategy.DEFAULT_NUMBER_OF_RETRIES)).instrumentationApplied(id, methodToSensorMap); verifyNoMoreInteractions(agentService); } }