Skip to content

Commit f184762

Browse files
authored
Update config & method parser in Android implementation (#144)
1 parent 111d0e4 commit f184762

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

splitio/example/pubspec.lock

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ packages:
170170
splitio_android:
171171
dependency: transitive
172172
description:
173-
name: splitio_android
174-
sha256: "44b0e1dddd374fc73fc1b5ef89598b96ea405d533a8211c06a45665f5d6187b5"
175-
url: "https://pub.dev"
176-
source: hosted
173+
path: "../../splitio_android"
174+
relative: true
175+
source: path
177176
version: "0.2.0"
178177
splitio_ios:
179178
dependency: transitive

splitio/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
publish_to: none # TODO
12
name: splitio
23
description: Official plugin for split.io, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience.
34
version: 0.2.0
@@ -19,7 +20,8 @@ flutter:
1920
dependencies:
2021
flutter:
2122
sdk: flutter
22-
splitio_android: ^0.2.0
23+
splitio_android:
24+
path: ../splitio_android
2325
splitio_ios: ^0.2.0
2426
splitio_platform_interface: ^1.5.0
2527

splitio_android/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ android {
3636
}
3737

3838
dependencies {
39-
implementation 'io.split.client:android-client:5.0.0'
39+
implementation 'io.split.client:android-client:5.1.0-rc1'
4040

4141
testImplementation 'junit:junit:4.13.2'
4242
testImplementation 'org.mockito:mockito-core:3.12.4'

splitio_android/android/src/main/java/io/split/splitio/SplitClientConfigHelper.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.Set;
1111
import java.util.concurrent.TimeUnit;
1212

13+
import io.split.android.client.RolloutCacheConfiguration;
1314
import io.split.android.client.ServiceEndpoints;
1415
import io.split.android.client.SplitClientConfig;
1516
import io.split.android.client.SplitFilter;
@@ -51,6 +52,9 @@ class SplitClientConfigHelper {
5152
private static final String READY_TIMEOUT = "readyTimeout";
5253
private static final String CERTIFICATE_PINNING_CONFIGURATION = "certificatePinningConfiguration";
5354
private static final String CERTIFICATE_PINNING_CONFIGURATION_PINS = "pins";
55+
private static final String ROLLOUT_CACHE_CONFIGURATION = "rolloutCacheConfiguration";
56+
private static final String ROLLOUT_CACHE_CONFIGURATION_EXPIRATION = "expirationDays";
57+
private static final String ROLLOUT_CACHE_CONFIGURATION_CLEAR_ON_INIT = "clearOnInit";
5458

5559
/**
5660
* Creates a {@link SplitClientConfig} object from a map.
@@ -242,6 +246,22 @@ static SplitClientConfig fromMap(@NonNull Map<String, Object> configurationMap,
242246
}
243247
}
244248

249+
Map<String, Object> rolloutCacheConfiguration = getObjectMap(configurationMap, ROLLOUT_CACHE_CONFIGURATION);
250+
if (rolloutCacheConfiguration != null) {
251+
Integer expirationDays = getInteger(rolloutCacheConfiguration, ROLLOUT_CACHE_CONFIGURATION_EXPIRATION);
252+
Boolean clearOnInit = getBoolean(rolloutCacheConfiguration, ROLLOUT_CACHE_CONFIGURATION_CLEAR_ON_INIT);
253+
if (expirationDays != null || clearOnInit != null) {
254+
RolloutCacheConfiguration.Builder cacheConfigBuilder = RolloutCacheConfiguration.builder();
255+
if (expirationDays != null) {
256+
cacheConfigBuilder.expirationDays(expirationDays);
257+
}
258+
if (clearOnInit != null) {
259+
cacheConfigBuilder.clearOnInit(clearOnInit);
260+
}
261+
builder.rolloutCacheConfiguration(cacheConfigBuilder.build());
262+
}
263+
}
264+
245265
return builder.serviceEndpoints(serviceEndpointsBuilder.build()).build();
246266
}
247267

splitio_android/android/src/main/java/io/split/splitio/SplitMethodParserImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ private static Map<String, Object> getSplitViewAsMap(@Nullable SplitView splitVi
474474
splitViewMap.put("configs", splitView.configs);
475475
splitViewMap.put("defaultTreatment", splitView.defaultTreatment);
476476
splitViewMap.put("sets", splitView.sets);
477+
splitViewMap.put("impressionsDisabled", splitView.impressionsDisabled);
477478

478479
return splitViewMap;
479480
}

splitio_android/android/src/test/java/io/split/splitio/SplitClientConfigHelperTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,20 @@ public void certificatePinningConfigurationValuesAreMappedCorrectly() {
219219
Set<CertificatePin> host2Pins = actualConfig.getPins().get("host2");
220220
assertEquals("sha256", host2Pins.iterator().next().getAlgorithm());
221221
}
222+
223+
@Test
224+
public void rolloutCacheConfigurationValuesAreMappedCorrectly() {
225+
Map<String, Object> configValues = new HashMap<>();
226+
Map<String, Object> rolloutCacheConfigValues = new HashMap<>();
227+
228+
rolloutCacheConfigValues.put("expirationDays", 5);
229+
rolloutCacheConfigValues.put("clearOnInit", true);
230+
configValues.put("rolloutCacheConfiguration", rolloutCacheConfigValues);
231+
232+
SplitClientConfig splitClientConfig = SplitClientConfigHelper
233+
.fromMap(configValues, mock(ImpressionListener.class));
234+
235+
assertEquals(5, splitClientConfig.rolloutCacheConfiguration().getExpirationDays());
236+
assertTrue(splitClientConfig.rolloutCacheConfiguration().isClearOnInit());
237+
}
222238
}

0 commit comments

Comments
 (0)