Skip to content

Update config & method parser in Android implementation #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions splitio/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ packages:
splitio_android:
dependency: transitive
description:
name: splitio_android
sha256: "44b0e1dddd374fc73fc1b5ef89598b96ea405d533a8211c06a45665f5d6187b5"
url: "https://pub.dev"
source: hosted
path: "../../splitio_android"
relative: true
source: path
version: "0.2.0"
splitio_ios:
dependency: transitive
Expand Down
4 changes: 3 additions & 1 deletion splitio/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
publish_to: none # TODO
name: splitio
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.
version: 0.2.0
Expand All @@ -19,7 +20,8 @@ flutter:
dependencies:
flutter:
sdk: flutter
splitio_android: ^0.2.0
splitio_android:
path: ../splitio_android
splitio_ios: ^0.2.0
splitio_platform_interface: ^1.5.0

Expand Down
2 changes: 1 addition & 1 deletion splitio_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {
}

dependencies {
implementation 'io.split.client:android-client:5.0.0'
implementation 'io.split.client:android-client:5.1.0-rc1'

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.12.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;

import io.split.android.client.RolloutCacheConfiguration;
import io.split.android.client.ServiceEndpoints;
import io.split.android.client.SplitClientConfig;
import io.split.android.client.SplitFilter;
Expand Down Expand Up @@ -51,6 +52,9 @@ class SplitClientConfigHelper {
private static final String READY_TIMEOUT = "readyTimeout";
private static final String CERTIFICATE_PINNING_CONFIGURATION = "certificatePinningConfiguration";
private static final String CERTIFICATE_PINNING_CONFIGURATION_PINS = "pins";
private static final String ROLLOUT_CACHE_CONFIGURATION = "rolloutCacheConfiguration";
private static final String ROLLOUT_CACHE_CONFIGURATION_EXPIRATION = "expirationDays";
private static final String ROLLOUT_CACHE_CONFIGURATION_CLEAR_ON_INIT = "clearOnInit";

/**
* Creates a {@link SplitClientConfig} object from a map.
Expand Down Expand Up @@ -242,6 +246,22 @@ static SplitClientConfig fromMap(@NonNull Map<String, Object> configurationMap,
}
}

Map<String, Object> rolloutCacheConfiguration = getObjectMap(configurationMap, ROLLOUT_CACHE_CONFIGURATION);
if (rolloutCacheConfiguration != null) {
Integer expirationDays = getInteger(rolloutCacheConfiguration, ROLLOUT_CACHE_CONFIGURATION_EXPIRATION);
Boolean clearOnInit = getBoolean(rolloutCacheConfiguration, ROLLOUT_CACHE_CONFIGURATION_CLEAR_ON_INIT);
if (expirationDays != null || clearOnInit != null) {
RolloutCacheConfiguration.Builder cacheConfigBuilder = RolloutCacheConfiguration.builder();
if (expirationDays != null) {
cacheConfigBuilder.expirationDays(expirationDays);
}
if (clearOnInit != null) {
cacheConfigBuilder.clearOnInit(clearOnInit);
}
builder.rolloutCacheConfiguration(cacheConfigBuilder.build());
}
}

return builder.serviceEndpoints(serviceEndpointsBuilder.build()).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ private static Map<String, Object> getSplitViewAsMap(@Nullable SplitView splitVi
splitViewMap.put("configs", splitView.configs);
splitViewMap.put("defaultTreatment", splitView.defaultTreatment);
splitViewMap.put("sets", splitView.sets);
splitViewMap.put("impressionsDisabled", splitView.impressionsDisabled);

return splitViewMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,20 @@ public void certificatePinningConfigurationValuesAreMappedCorrectly() {
Set<CertificatePin> host2Pins = actualConfig.getPins().get("host2");
assertEquals("sha256", host2Pins.iterator().next().getAlgorithm());
}

@Test
public void rolloutCacheConfigurationValuesAreMappedCorrectly() {
Map<String, Object> configValues = new HashMap<>();
Map<String, Object> rolloutCacheConfigValues = new HashMap<>();

rolloutCacheConfigValues.put("expirationDays", 5);
rolloutCacheConfigValues.put("clearOnInit", true);
configValues.put("rolloutCacheConfiguration", rolloutCacheConfigValues);

SplitClientConfig splitClientConfig = SplitClientConfigHelper
.fromMap(configValues, mock(ImpressionListener.class));

assertEquals(5, splitClientConfig.rolloutCacheConfiguration().getExpirationDays());
assertTrue(splitClientConfig.rolloutCacheConfiguration().isClearOnInit());
}
}