Search in sources :

Example 1 with StatisticsConnectionService

use of com.intellij.internal.statistic.connect.StatisticsConnectionService in project intellij-community by JetBrains.

the class RemotelyConfigurableStatServiceTest method testIncorrectUrlSending.

@Test
public void testIncorrectUrlSending() {
    RemotelyConfigurableStatisticsService service = new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(STAT_CONFIG_URL, STAT_URL), new StatisticsHttpClientSender(), new StatisticsUploadAssistant() {

        @Override
        public String getData(@NotNull Set<String> disabledGroups) {
            return "group:key1=11";
        }
    });
    StatisticsResult result = service.send();
    assertEquals(StatisticsResult.ResultCode.SENT_WITH_ERRORS, result.getCode());
}
Also used : StatisticsResult(com.intellij.internal.statistic.connect.StatisticsResult) StatisticsConnectionService(com.intellij.internal.statistic.connect.StatisticsConnectionService) StatisticsHttpClientSender(com.intellij.internal.statistic.connect.StatisticsHttpClientSender) RemotelyConfigurableStatisticsService(com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService) StatisticsUploadAssistant(com.intellij.internal.statistic.StatisticsUploadAssistant) Test(org.junit.Test)

Example 2 with StatisticsConnectionService

use of com.intellij.internal.statistic.connect.StatisticsConnectionService in project android by JetBrains.

the class AndroidStatisticsService method areStatisticsAuthorized.

/**
   * Checks whether the statistics service has a service URL and is authorized to send statistics.
   *
   * @return A {@link StatisticsResult} with a {@link StatisticsResult.ResultCode#SEND} result code on success, otherwise one of the error
   * result codes.
   */
static StatisticsResult areStatisticsAuthorized() {
    // Get the redirected URL
    final StatisticsConnectionService service = new StatisticsConnectionService();
    final String serviceUrl = service.getServiceUrl();
    // Check server provided an URL and enabled sending stats.
    if (serviceUrl == null) {
        return new StatisticsResult(StatisticsResult.ResultCode.ERROR_IN_CONFIG, "ERROR");
    }
    if (!service.isTransmissionPermitted()) {
        return new StatisticsResult(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, "NOT_PERMITTED");
    }
    return new StatisticsResult(StatisticsResult.ResultCode.SEND, "OK");
}
Also used : StatisticsResult(com.intellij.internal.statistic.connect.StatisticsResult) StatisticsConnectionService(com.intellij.internal.statistic.connect.StatisticsConnectionService)

Example 3 with StatisticsConnectionService

use of com.intellij.internal.statistic.connect.StatisticsConnectionService in project intellij-community by JetBrains.

the class RemotelyConfigurableStatServiceTest method testErrorInRemoteConfiguration.

@Test
public void testErrorInRemoteConfiguration() {
    RemotelyConfigurableStatisticsService service = new RemotelyConfigurableStatisticsService(new StatisticsConnectionService(STAT_CONFIG_URL, null), new StatisticsHttpClientSender(), new StatisticsUploadAssistant());
    StatisticsResult result = service.send();
    assertEquals(StatisticsResult.ResultCode.ERROR_IN_CONFIG, result.getCode());
}
Also used : StatisticsResult(com.intellij.internal.statistic.connect.StatisticsResult) StatisticsConnectionService(com.intellij.internal.statistic.connect.StatisticsConnectionService) StatisticsHttpClientSender(com.intellij.internal.statistic.connect.StatisticsHttpClientSender) RemotelyConfigurableStatisticsService(com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService) StatisticsUploadAssistant(com.intellij.internal.statistic.StatisticsUploadAssistant) Test(org.junit.Test)

Example 4 with StatisticsConnectionService

use of com.intellij.internal.statistic.connect.StatisticsConnectionService in project intellij-community by JetBrains.

the class RemotelyConfigurableStatServiceTest method testStatisticsConnectionServiceDefaultSettings.

@Test
public void testStatisticsConnectionServiceDefaultSettings() {
    StatisticsConnectionService connectionService = new StatisticsConnectionService(STAT_CONFIG_URL, STAT_URL);
    assertEquals(STAT_URL, connectionService.getServiceUrl());
    assertTrue(connectionService.isTransmissionPermitted());
    String[] attributeNames = connectionService.getAttributeNames();
    assertEquals(attributeNames.length, 2);
    assertEquals(attributeNames[0], "url");
    assertEquals(attributeNames[1], "permitted");
}
Also used : StatisticsConnectionService(com.intellij.internal.statistic.connect.StatisticsConnectionService) Test(org.junit.Test)

Example 5 with StatisticsConnectionService

use of com.intellij.internal.statistic.connect.StatisticsConnectionService in project intellij-community by JetBrains.

the class RemotelyConfigurableStatServiceTest method testRemotelyDisabledTransmission.

@Test
public void testRemotelyDisabledTransmission() {
    RemotelyConfigurableStatisticsService service = new RemotelyConfigurableStatisticsService(new StatisticsConnectionService() {

        @Override
        public boolean isTransmissionPermitted() {
            return false;
        }
    }, new StatisticsHttpClientSender(), new StatisticsUploadAssistant());
    StatisticsResult result = service.send();
    assertEquals(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, result.getCode());
}
Also used : StatisticsResult(com.intellij.internal.statistic.connect.StatisticsResult) StatisticsConnectionService(com.intellij.internal.statistic.connect.StatisticsConnectionService) StatisticsHttpClientSender(com.intellij.internal.statistic.connect.StatisticsHttpClientSender) RemotelyConfigurableStatisticsService(com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService) StatisticsUploadAssistant(com.intellij.internal.statistic.StatisticsUploadAssistant) Test(org.junit.Test)

Aggregations

StatisticsConnectionService (com.intellij.internal.statistic.connect.StatisticsConnectionService)7 RemotelyConfigurableStatisticsService (com.intellij.internal.statistic.connect.RemotelyConfigurableStatisticsService)5 StatisticsHttpClientSender (com.intellij.internal.statistic.connect.StatisticsHttpClientSender)5 StatisticsResult (com.intellij.internal.statistic.connect.StatisticsResult)5 Test (org.junit.Test)5 StatisticsUploadAssistant (com.intellij.internal.statistic.StatisticsUploadAssistant)4 StatisticsService (com.intellij.internal.statistic.connect.StatisticsService)1 ApplicationInfoImpl (com.intellij.openapi.application.impl.ApplicationInfoImpl)1