Search in sources :

Example 1 with InsightsService

use of com.newrelic.agent.service.analytics.InsightsService in project newrelic-java-agent by newrelic.

the class InstrumentationTransactionTest method testExceptionInTransactionInitialization.

@Test
public void testExceptionInTransactionInitialization() {
    ServiceManager serviceManager = Mockito.spy(ServiceFactory.getServiceManager());
    InsightsService insightsService = Mockito.spy(serviceManager.getInsights());
    Mockito.when(serviceManager.getInsights()).thenReturn(insightsService);
    // Force throw an exception in the Transaction constructor
    Mockito.doThrow(new RuntimeException()).when(insightsService).getTransactionInsights(Mockito.any(AgentConfig.class));
    ServiceFactory.setServiceManager(serviceManager);
    // Tracing the current test method doesn't allow us to use the
    // mocked RuntimeException so we'll put it on a dummy method instead
    doNothing();
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ServiceManager(com.newrelic.agent.service.ServiceManager) InsightsService(com.newrelic.agent.service.analytics.InsightsService) Test(org.junit.Test)

Aggregations

AgentConfig (com.newrelic.agent.config.AgentConfig)1 ServiceManager (com.newrelic.agent.service.ServiceManager)1 InsightsService (com.newrelic.agent.service.analytics.InsightsService)1 Test (org.junit.Test)1