Skip to content

Commit

Permalink
Merge pull request #171 from Countly/server_config
Browse files Browse the repository at this point in the history
Adding initial Server config
  • Loading branch information
ArtursKadikis authored Apr 23, 2023
2 parents 244a99f + 958eb96 commit ff94f22
Show file tree
Hide file tree
Showing 26 changed files with 726 additions and 46 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ apply plugin: 'com.android.application'
//apply plugin: 'com.huawei.agconnect'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

/*
//for automatic symbol upload
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/ly/count/android/demo/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public void callback(String error) {

.setEnableAttribution(true)

.enableServerConfiguration()

.setUserProperties(customUserProperties);

Countly.sharedInstance().init(config);
Expand Down
42 changes: 21 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.8.0'
repositories {
maven {
url 'https://developer.huawei.com/repo/'
}
google()
mavenCentral()
maven {
url 'https://developer.huawei.com/repo/'
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'

classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.google.gms:google-services:4.3.10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3"
}
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3"
}
}

allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
repositories {
google()
mavenCentral()
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
repositories {
google()
mavenCentral()
}
}
12 changes: 6 additions & 6 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Apr 25 19:27:00 EEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
#Sun Apr 23 22:46:09 EEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion sdk-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '31.0.0'
buildToolsVersion '33.0.0'
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,26 @@ public class ConnectionProcessorTests {
DeviceIdProvider mockDeviceId;
String testDeviceId;
ModuleLog moduleLog;
ConfigurationProvider configurationProviderFake;

@Before
public void setUp() {
configurationProviderFake = new ConfigurationProvider() {
@Override public boolean getNetworkingEnabled() {
return true;
}

@Override public boolean getTrackingEnabled() {
return true;
}
};

Countly.sharedInstance().setLoggingEnabled(true);
mockStore = mock(CountlyStore.class);
mockDeviceId = mock(DeviceIdProvider.class);
moduleLog = mock(ModuleLog.class);

connectionProcessor = new ConnectionProcessor("http://server", mockStore, mockDeviceId, null, null, moduleLog);
connectionProcessor = new ConnectionProcessor("http://server", mockStore, mockDeviceId, configurationProviderFake, null, null, moduleLog);
testDeviceId = "123";
}

Expand All @@ -74,7 +85,7 @@ public void testConstructorAndGetters() {
final String serverURL = "https://secureserver";
final CountlyStore mockStore = mock(CountlyStore.class);
final DeviceIdProvider mockDeviceId = mock(DeviceIdProvider.class);
final ConnectionProcessor connectionProcessor1 = new ConnectionProcessor(serverURL, mockStore, mockDeviceId, null, null, moduleLog);
final ConnectionProcessor connectionProcessor1 = new ConnectionProcessor(serverURL, mockStore, mockDeviceId, configurationProviderFake, null, null, moduleLog);
assertEquals(serverURL, connectionProcessor1.getServerURL());
assertSame(mockStore, connectionProcessor1.getCountlyStore());
}
Expand Down Expand Up @@ -143,7 +154,7 @@ public void urlConnectionCustomHeaderValues() throws IOException {
customValues.put("5", "");
customValues.put("6", null);

ConnectionProcessor connectionProcessor = new ConnectionProcessor("http://server", mockStore, mockDeviceId, null, customValues, moduleLog);
ConnectionProcessor connectionProcessor = new ConnectionProcessor("http://server", mockStore, mockDeviceId, configurationProviderFake, null, customValues, moduleLog);
final URLConnection urlConnection = connectionProcessor.urlConnectionForServerRequest("eventData", null);

assertEquals("bb", urlConnection.getRequestProperty("aa"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ public void validatingAnythingSetInStorageSeparate() {
CountlyStore.cachePushData("mnc", null, getContext());
assertTrue(sp.anythingSetInStorage());
store.clear();

sp.setServerConfig("qwe");
assertTrue(sp.anythingSetInStorage());
store.clear();
}

/**
Expand Down Expand Up @@ -680,6 +684,9 @@ public void validatingAnythingSetInStorageAggregate() {

CountlyStore.cachePushData("mnc", "uio", getContext());
assertTrue(sp.anythingSetInStorage());

sp.setServerConfig("qwe");
assertTrue(sp.anythingSetInStorage());
}

/**
Expand Down Expand Up @@ -732,4 +739,12 @@ public void getEventsForRequestAndEmptyEventQueueWithSimpleEvents() throws Unsup
assertEquals(expected, sp.getEventsForRequestAndEmptyEventQueue());
Assert.assertEquals(0, sp.getEventQueueSize());
}

@Test
public void getSetServerConfig() {
store.clear();
Assert.assertNull(sp.getServerConfig());
sp.setServerConfig("qwe");
Assert.assertEquals("qwe", sp.getServerConfig());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void tearDown() {
//making sure all needed modules are added
@Test
public void checkup() {
Assert.assertEquals(14, mCountly.modules.size());
Assert.assertEquals(15, mCountly.modules.size());
}

//just making sure nothing throws exceptions
Expand Down
Loading

0 comments on commit ff94f22

Please sign in to comment.