// Suppress non relevant warning due to mockito internal stuff @SuppressWarnings("unchecked") private AppInsightsConfigurationBuilder createMockParser( boolean withChannel, boolean setChannel, boolean withPerformanceModules) { AppInsightsConfigurationBuilder mockParser = Mockito.mock(AppInsightsConfigurationBuilder.class); ApplicationInsightsXmlConfiguration appConf = new ApplicationInsightsXmlConfiguration(); appConf.setSdkLogger(new SDKLoggerXmlElement()); if (withChannel) { ChannelXmlElement channelXmlElement = new ChannelXmlElement(); channelXmlElement.setEndpointAddress(MOCK_ENDPOINT); String channelType = null; if (setChannel) { channelType = "com.microsoft.applicationinsights.internal.channel.stdout.StdOutChannel"; channelXmlElement.setType(channelType); } appConf.setChannel(channelXmlElement); } if (withPerformanceModules) { PerformanceCountersXmlElement performanceCountersXmlElement = new PerformanceCountersXmlElement(); appConf.setPerformance(performanceCountersXmlElement); } Mockito.doReturn(appConf).when(mockParser).build(any(InputStream.class)); return mockParser; }