// 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;
  }
  @Test
  public void testWithEmptySections() {
    AppInsightsConfigurationBuilder mockParser =
        Mockito.mock(AppInsightsConfigurationBuilder.class);

    ApplicationInsightsXmlConfiguration appConf = new ApplicationInsightsXmlConfiguration();
    appConf.setInstrumentationKey(MOCK_IKEY);
    appConf.setTelemetryInitializers(null);
    appConf.setContextInitializers(null);
    appConf.setModules(null);
    appConf.setSdkLogger(null);
    Mockito.doReturn(appConf).when(mockParser).build(any(InputStream.class));

    TelemetryConfiguration mockConfiguration = new TelemetryConfiguration();

    initializeWithFactory(mockParser, mockConfiguration);

    assertEquals(mockConfiguration.isTrackingDisabled(), false);
    assertEquals(mockConfiguration.getInstrumentationKey(), MOCK_IKEY);
    assertEquals(mockConfiguration.getContextInitializers().size(), 2);
    assertTrue(mockConfiguration.getChannel() instanceof InProcessTelemetryChannel);
  }