use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class UtilizationServiceTest method before.
@Before
public void before() {
MockServiceManager mockServiceManager = new MockServiceManager();
config = mock(AgentConfig.class);
MockConfigService configService = new MockConfigService(null);
configService.setAgentConfig(config);
ServiceFactory.setServiceManager(mockServiceManager);
mockServiceManager.setConfigService(configService);
ThreadService mockThreadService = mock(ThreadService.class);
mockServiceManager.setThreadService(mockThreadService);
// Do not make AWS/Azure/GCP/PCF calls. Unit tests should work even without internet connection :)
when(config.getValue(UtilizationService.DETECT_DOCKER_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_AWS_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_AZURE_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_GOOGLE_CLOUD_PROVIDER_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_PIVOTAL_CLOUD_FOUNDRY_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_KUBERNETES_KEY, true)).thenReturn(false);
UtilizationDataConfig utilDataConfig = mock(UtilizationDataConfig.class);
when(config.getUtilizationDataConfig()).thenReturn(utilDataConfig);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class NewRelicApiImplementationTest method mockOutServices.
private void mockOutServices() {
errorService = Mockito.mock(ErrorService.class);
IRPMService rpmService = Mockito.mock(IRPMService.class);
Mockito.when(rpmService.getErrorService()).thenReturn(errorService);
RPMServiceManager rpmServiceManager = Mockito.mock(RPMServiceManager.class);
Mockito.when(rpmServiceManager.getRPMService()).thenReturn(rpmService);
MockServiceManager sm = new MockServiceManager();
sm.setRPMServiceManager(rpmServiceManager);
ServiceFactory.setServiceManager(sm);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class CloudUtilityTest method before.
@Before
public void before() {
MockServiceManager mockServiceManager = new MockServiceManager();
mockServiceManager.setSamplerService(mock(SamplerService.class));
mockStatsService = mock(StatsService.class);
mockServiceManager.setStatsService(mockStatsService);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class DockerDataTest method testNoDockerError.
@Test
public void testNoDockerError() throws Exception {
MockCoreService.getMockAgentAndBootstrapTheServiceManager();
MockServiceManager mockServiceManager = new MockServiceManager();
StatsService spy = Mockito.spy(new StatsServiceImpl());
mockServiceManager.setStatsService(spy);
ServiceFactory.setServiceManager(mockServiceManager);
String validDockerID = "47cbd16b77c50cbf71401c069cd2189f0e659af17d5a2daca3bddf59d8a870b2";
StringReader reader = new StringReader("2:cpu:/docker/" + validDockerID);
Assert.assertEquals(validDockerID, dockerData.readFile(reader));
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class UtilizationCrossAgentTests method setConfig.
/*
* Create a mock service manager with a config service with the given utilization values
*/
private static void setConfig(String billingHostname, Long totalRam, Integer logicalProcessors) {
Map<String, Object> config = new HashMap<>();
Map<String, Object> values = new HashMap<>();
values.put("billing_hostname", billingHostname);
values.put("total_ram_mib", totalRam);
values.put("logical_processors", logicalProcessors);
config.put(UtilizationDataConfig.PROPERTY_NAME, values);
config.put("app_name", "CATs");
ConfigService configService = new MockConfigService(AgentConfigImpl.createAgentConfig(config));
MockServiceManager mockServiceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(mockServiceManager);
}
Aggregations