diff --git a/client/src/main/java/io/split/client/CacheUpdaterService.java b/client/src/main/java/io/split/client/CacheUpdaterService.java new file mode 100644 index 000000000..6823fdefd --- /dev/null +++ b/client/src/main/java/io/split/client/CacheUpdaterService.java @@ -0,0 +1,90 @@ +package io.split.client; + +import com.google.common.collect.Lists; +import io.split.cache.SplitCache; +import io.split.client.dtos.ConditionType; +import io.split.client.dtos.MatcherCombiner; +import io.split.client.dtos.Partition; +import io.split.engine.experiments.ParsedCondition; +import io.split.engine.experiments.ParsedSplit; +import io.split.engine.matchers.AllKeysMatcher; +import io.split.engine.matchers.AttributeMatcher; +import io.split.engine.matchers.CombiningMatcher; +import io.split.engine.matchers.strings.WhitelistMatcher; +import io.split.grammar.Treatments; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Comparator; +import java.util.stream.Collectors; + +public final class CacheUpdaterService { + + private static String LOCALHOST = "localhost"; + private SplitCache _splitCache; + + public CacheUpdaterService(SplitCache splitCache) { + _splitCache = splitCache; + } + + public void updateCache(Map map) { + _splitCache.clear(); + for (Map.Entry entrySplit : map.entrySet()) { + SplitAndKey splitAndKey = entrySplit.getKey(); + String splitName = splitAndKey.split(); + String splitKey = splitAndKey.key(); + LocalhostSplit localhostSplit = entrySplit.getValue(); + ParsedSplit split = _splitCache.get(splitName); + List conditions = getConditions(splitKey, split, localhostSplit.treatment); + String treatment = conditions.size() > 0 ? Treatments.CONTROL : localhostSplit.treatment; + Map configurations = new HashMap<>(); + if(split != null && split.configurations().size() > 0) { + configurations = split.configurations(); + } + configurations.put(localhostSplit.treatment, localhostSplit.config); + + split = new ParsedSplit(splitName, 0, false, treatment,conditions, LOCALHOST, 0, 100, 0, 0, configurations); + _splitCache.put(split); + } + } + + private List getConditions(String splitKey, ParsedSplit split, String treatment){ + List conditions = split == null ? new ArrayList<>() : split.parsedConditions().stream().collect(Collectors.toList()); + Partition partition = new Partition(); + partition.treatment = treatment; + partition.size = 100; + + if(splitKey != null) { + conditions.add(createWhitelistCondition(splitKey, partition)); + } + else { + conditions = conditions.stream().filter(pc -> ConditionType.WHITELIST.equals(pc.conditionType())).collect(Collectors.toList()); + conditions.add(createRolloutCondition(partition)); + } + conditions.sort(Comparator.comparing(ParsedCondition::conditionType)); + return conditions; + } + + private ParsedCondition createWhitelistCondition(String splitKey, Partition partition) { + ParsedCondition parsedCondition = new ParsedCondition(ConditionType.WHITELIST, + new CombiningMatcher(MatcherCombiner.AND, + Lists.newArrayList(new AttributeMatcher(null, new WhitelistMatcher(Lists.newArrayList(splitKey)), false))), + Lists.newArrayList(partition), splitKey); + return parsedCondition; + } + + private ParsedCondition createRolloutCondition(Partition partition) { + Partition rolloutPartition = new Partition(); + rolloutPartition.treatment = "-"; + rolloutPartition.size = 0; + ParsedCondition parsedCondition = new ParsedCondition(ConditionType.ROLLOUT, + new CombiningMatcher(MatcherCombiner.AND, + Lists.newArrayList(new AttributeMatcher(null, new AllKeysMatcher(), false))), + Lists.newArrayList(partition, rolloutPartition), "LOCAL"); + + return parsedCondition; + } + +} diff --git a/client/src/main/java/io/split/client/LocalhostSplitClient.java b/client/src/main/java/io/split/client/LocalhostSplitClient.java deleted file mode 100644 index 2c5c191d5..000000000 --- a/client/src/main/java/io/split/client/LocalhostSplitClient.java +++ /dev/null @@ -1,142 +0,0 @@ -package io.split.client; - -import io.split.client.api.Key; -import io.split.client.api.SplitResult; -import io.split.grammar.Treatments; -import io.split.inputValidation.KeyValidator; -import io.split.inputValidation.SplitNameValidator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeoutException; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * An implementation of SplitClient that considers all partitions - * passed in the constructor to be 100% on for all users, and - * any other split to be 100% off for all users. This implementation - * is useful for using Codigo in localhost environment. - * - * @author adil - */ -public final class LocalhostSplitClient implements SplitClient { - private static final Logger _log = LoggerFactory.getLogger(LocalhostSplitClient.class); - private static SplitResult SPLIT_RESULT_CONTROL = new SplitResult(Treatments.CONTROL, null); - - private Map _map; - - public LocalhostSplitClient(Map map) { - checkNotNull(map, "map must not be null"); - _map = map; - } - - @Override - public String getTreatment(String key, String split) { - return getTreatmentAndConfigInternal(key, split).treatment(); - } - - @Override - public String getTreatment(String key, String split, Map attributes) { - return getTreatmentAndConfigInternal(key, split).treatment(); - } - - @Override - public String getTreatment(Key key, String split, Map attributes) { - return getTreatmentAndConfigInternal(key.matchingKey(), split, attributes).treatment(); - } - - @Override - public SplitResult getTreatmentWithConfig(String key, String split) { - return getTreatmentAndConfigInternal(key, split); - } - - @Override - public SplitResult getTreatmentWithConfig(String key, String split, Map attributes) { - return getTreatmentAndConfigInternal(key, split, attributes); - } - - @Override - public SplitResult getTreatmentWithConfig(Key key, String split, Map attributes) { - return getTreatmentAndConfigInternal(key.matchingKey(), split, attributes); - } - - @Override - public void destroy() { - _map.clear(); - } - - @Override - public boolean track(String key, String trafficType, String eventType) { - return false; - } - - @Override - public boolean track(String key, String trafficType, String eventType, double value) { - return false; - } - - @Override - public boolean track(String key, String trafficType, String eventType, Map properties) { - return false; - } - - @Override - public boolean track(String key, String trafficType, String eventType, double value, Map properties) { - return false; - } - - @Override - public void blockUntilReady() throws TimeoutException, InterruptedException { - // LocalhostSplitClient is always ready - } - - public void updateFeatureToTreatmentMap(Map map) { - if (map == null) { - _log.warn("A null map was passed as an update. Ignoring this update."); - return; - } - _map = map; - } - - private SplitResult getTreatmentAndConfigInternal(String key, String split, Map attributes) { - boolean keyIsValid = KeyValidator.isValid(key, "matchingKey", "getTreatment"); - - if (!keyIsValid) { - return SPLIT_RESULT_CONTROL; - } - - Optional splitName = SplitNameValidator.isValid(split, "getTreatment"); - - if (!splitName.isPresent()) { - return SPLIT_RESULT_CONTROL; - } - - split = splitName.get(); - - SplitAndKey override = SplitAndKey.of(split, key); - if (_map.containsKey(override)) { - return toSplitResult(_map.get(override)); - } - - SplitAndKey splitDefaultTreatment = SplitAndKey.of(split); - - LocalhostSplit localhostSplit = _map.get(splitDefaultTreatment); - - if (localhostSplit == null) { - return SPLIT_RESULT_CONTROL; - } - - return toSplitResult(localhostSplit); - } - - private SplitResult toSplitResult(LocalhostSplit localhostSplit) { - return new SplitResult(localhostSplit.treatment,localhostSplit.config); - } - - private SplitResult getTreatmentAndConfigInternal(String key, String split) { - return getTreatmentAndConfigInternal(key, split, null); - } -} diff --git a/client/src/main/java/io/split/client/LocalhostSplitClientAndFactory.java b/client/src/main/java/io/split/client/LocalhostSplitClientAndFactory.java deleted file mode 100644 index 15b5341e3..000000000 --- a/client/src/main/java/io/split/client/LocalhostSplitClientAndFactory.java +++ /dev/null @@ -1,101 +0,0 @@ -package io.split.client; - -import io.split.client.api.Key; -import io.split.client.api.SplitResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Map; -import java.util.concurrent.TimeoutException; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * An implementation of SplitClient that considers all partitions - * passed in the constructor to be 100% on for all users, and - * any other split to be 100% off for all users. This implementation - * is useful for using Split in localhost environment. - * - * @author adil - */ -public final class LocalhostSplitClientAndFactory implements SplitClient { - private static final Logger _log = LoggerFactory.getLogger(LocalhostSplitClientAndFactory.class); - - private LocalhostSplitFactory _factory; - private LocalhostSplitClient _splitClient; - - public LocalhostSplitClientAndFactory(LocalhostSplitFactory container, LocalhostSplitClient client) { - _factory = checkNotNull(container); - _splitClient = checkNotNull(client); - } - - @Override - public String getTreatment(String key, String split) { - return _splitClient.getTreatment(key, split); - } - - @Override - public String getTreatment(String key, String split, Map attributes) { - return _splitClient.getTreatment(key, split, attributes); - } - - @Override - public String getTreatment(Key key, String split, Map attributes) { - return _splitClient.getTreatment(key.matchingKey(), split, attributes); - } - - @Override - public SplitResult getTreatmentWithConfig(String key, String split) { - return _splitClient.getTreatmentWithConfig(key, split); - } - - @Override - public SplitResult getTreatmentWithConfig(String key, String split, Map attributes) { - return _splitClient.getTreatmentWithConfig(key, split, attributes); - } - - @Override - public SplitResult getTreatmentWithConfig(Key key, String split, Map attributes) { - return _splitClient.getTreatmentWithConfig(key, split, attributes); - } - - public void updateFeatureToTreatmentMap(Map map) { - if (map == null) { - _log.warn("A null map was passed as an update. Ignoring this update."); - return; - } - _splitClient.updateFeatureToTreatmentMap(map); - } - - @Override - public void destroy() { - _factory.destroy(); - _splitClient.destroy(); - } - - @Override - public boolean track(String key, String trafficType, String eventType) { - return _splitClient.track(key, trafficType, eventType); - } - - @Override - public boolean track(String key, String trafficType, String eventType, double value) { - return _splitClient.track(key, trafficType, eventType, value); - } - - @Override - public boolean track(String key, String trafficType, String eventType, Map properties) { - return _splitClient.track(key, trafficType, eventType, properties); - } - - @Override - public boolean track(String key, String trafficType, String eventType, double value, Map properties) { - return _splitClient.track(key, trafficType, eventType, value, properties); - } - - @Override - public void blockUntilReady() throws TimeoutException, InterruptedException { - _splitClient.blockUntilReady(); - } - -} diff --git a/client/src/main/java/io/split/client/LocalhostSplitFactory.java b/client/src/main/java/io/split/client/LocalhostSplitFactory.java index 940fd2fbe..0ec01f8c9 100644 --- a/client/src/main/java/io/split/client/LocalhostSplitFactory.java +++ b/client/src/main/java/io/split/client/LocalhostSplitFactory.java @@ -1,5 +1,11 @@ package io.split.client; +import io.split.cache.InMemoryCacheImp; +import io.split.cache.SplitCache; +import io.split.client.impressions.ImpressionsManager; +import io.split.engine.SDKReadinessGates; +import io.split.engine.evaluator.EvaluatorImp; +import io.split.engine.metrics.Metrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,9 +29,10 @@ public final class LocalhostSplitFactory implements SplitFactory { static final String FILENAME = ".split"; static final String LOCALHOST = "localhost"; - private final LocalhostSplitClientAndFactory _client; + private final SplitClient _client; private final LocalhostSplitManager _manager; private final AbstractLocalhostSplitFile _splitFile; + private final CacheUpdaterService _cacheUpdaterService; public static LocalhostSplitFactory createLocalhostSplitFactory(SplitClientConfig config) throws IOException { String directory = System.getProperty("user.home"); @@ -44,7 +51,15 @@ public LocalhostSplitFactory(String directory, String file) throws IOException { } Map splitAndKeyToTreatment = _splitFile.readOnSplits(); - _client = new LocalhostSplitClientAndFactory(this, new LocalhostSplitClient(splitAndKeyToTreatment)); + SplitCache splitCache = new InMemoryCacheImp(); + SDKReadinessGates sdkReadinessGates = new SDKReadinessGates(); + + sdkReadinessGates.splitsAreReady(); + _cacheUpdaterService = new CacheUpdaterService(splitCache); + _cacheUpdaterService.updateCache(splitAndKeyToTreatment); + _client = new SplitClientImpl(this, splitCache, + new ImpressionsManager.NoOpImpressionsManager(), new Metrics.NoopMetrics(), new NoopEventClient(), + SplitClientConfig.builder().setBlockUntilReadyTimeout(1).build(), sdkReadinessGates, new EvaluatorImp(splitCache)); _manager = LocalhostSplitManager.of(splitAndKeyToTreatment); _splitFile.registerWatcher(); @@ -73,7 +88,7 @@ public boolean isDestroyed() { } public void updateFeatureToTreatmentMap(Map featureToTreatmentMap) { - _client.updateFeatureToTreatmentMap(featureToTreatmentMap); + _cacheUpdaterService.updateCache(featureToTreatmentMap); _manager.updateFeatureToTreatmentMap(featureToTreatmentMap); } } diff --git a/client/src/main/java/io/split/client/LocalhostSplitManager.java b/client/src/main/java/io/split/client/LocalhostSplitManager.java index 26a8118fc..dc72ea4d1 100644 --- a/client/src/main/java/io/split/client/LocalhostSplitManager.java +++ b/client/src/main/java/io/split/client/LocalhostSplitManager.java @@ -77,7 +77,7 @@ public void blockUntilReady() throws TimeoutException, InterruptedException { @Override public SplitView split(String featureName) { - if (!_splitAndKeyToTreatmentMap.containsKey(featureName)) { + if (!_splitToTreatmentsMap.containsKey(featureName)) { return null; } diff --git a/client/src/main/java/io/split/client/SplitClientImpl.java b/client/src/main/java/io/split/client/SplitClientImpl.java index 120ec00d4..7792f5a1f 100644 --- a/client/src/main/java/io/split/client/SplitClientImpl.java +++ b/client/src/main/java/io/split/client/SplitClientImpl.java @@ -1,16 +1,15 @@ package io.split.client; +import io.split.cache.SplitCache; import io.split.client.api.Key; import io.split.client.api.SplitResult; import io.split.client.dtos.Event; import io.split.client.impressions.Impression; import io.split.client.impressions.ImpressionsManager; -import io.split.cache.SplitCache; -import io.split.engine.evaluator.Evaluator; import io.split.engine.SDKReadinessGates; +import io.split.engine.evaluator.Evaluator; import io.split.engine.evaluator.EvaluatorImp; import io.split.engine.evaluator.Labels; - import io.split.engine.metrics.Metrics; import io.split.grammar.Treatments; import io.split.inputValidation.EventsValidator; diff --git a/client/src/main/java/io/split/client/SplitFactoryBuilder.java b/client/src/main/java/io/split/client/SplitFactoryBuilder.java index 4a95228b4..f18032416 100644 --- a/client/src/main/java/io/split/client/SplitFactoryBuilder.java +++ b/client/src/main/java/io/split/client/SplitFactoryBuilder.java @@ -52,7 +52,7 @@ public static synchronized SplitFactory build(String apiToken, SplitClientConfig * * @throws IOException if there were problems reading the override file from disk. */ - public static SplitFactory local() throws IOException { + public static SplitFactory local() throws IOException, URISyntaxException { return LocalhostSplitFactory.createLocalhostSplitFactory(SplitClientConfig.builder().build()); } @@ -62,7 +62,7 @@ public static SplitFactory local() throws IOException { * @return config Split config file * @throws IOException if there were problems reading the override file from disk. */ - public static SplitFactory local(SplitClientConfig config) throws IOException { + public static SplitFactory local(SplitClientConfig config) throws IOException, URISyntaxException { return LocalhostSplitFactory.createLocalhostSplitFactory(config); } diff --git a/client/src/main/java/io/split/engine/sse/client/SSEClient.java b/client/src/main/java/io/split/engine/sse/client/SSEClient.java index 00507a6d2..26d2ea934 100644 --- a/client/src/main/java/io/split/engine/sse/client/SSEClient.java +++ b/client/src/main/java/io/split/engine/sse/client/SSEClient.java @@ -127,7 +127,7 @@ private void connectAndLoop(URI uri, CountDownLatch signal) { _statusCallback.apply(StatusMessage.RETRYABLE_ERROR); return; } catch (IOException exc) { // Other type of connection error - _log.info(String.format("SSE connection ended abruptly: %s. Retying", exc.getMessage())); + _log.info(String.format("SSE connection ended abruptly: %s. Retrying", exc.getMessage())); _statusCallback.apply(StatusMessage.RETRYABLE_ERROR); return; } diff --git a/client/src/test/java/io/split/client/CacheUpdaterServiceTest.java b/client/src/test/java/io/split/client/CacheUpdaterServiceTest.java new file mode 100644 index 000000000..9d6d30140 --- /dev/null +++ b/client/src/test/java/io/split/client/CacheUpdaterServiceTest.java @@ -0,0 +1,45 @@ +package io.split.client; + +import io.split.cache.InMemoryCacheImp; +import io.split.cache.SplitCache; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +public class CacheUpdaterServiceTest { + + private static final String OFF_TREATMENT = "off"; + private static final String ON_TREATMENT = "on"; + private static final String MY_FEATURE = "my_feature"; + private SplitClientConfig config = SplitClientConfig.builder().setBlockUntilReadyTimeout(100).build(); + + @Test + public void testCacheUpdate() { + SplitCache splitCache = new InMemoryCacheImp(); + CacheUpdaterService cacheUpdaterService = new CacheUpdaterService(splitCache); + cacheUpdaterService.updateCache(getMap()); + Assert.assertNotNull(splitCache.get(MY_FEATURE)); + } + + public Map getMap() { + Map map = new HashMap<>(); + SplitAndKey splitAndKey = new SplitAndKey(MY_FEATURE, "onley_key"); + LocalhostSplit split = new LocalhostSplit(OFF_TREATMENT, "{\\\"desc\\\" : \\\"this applies only to OFF and only for only_key. The rest will receive ON\\\"}"); + map.put(splitAndKey, split); + splitAndKey = new SplitAndKey("other_feature_2", null); + split = new LocalhostSplit(ON_TREATMENT, null); + map.put(splitAndKey, split); + splitAndKey = new SplitAndKey("other_feature_3", null); + split = new LocalhostSplit(OFF_TREATMENT, null); + map.put(splitAndKey, split); + splitAndKey = new SplitAndKey(MY_FEATURE, "key"); + split = new LocalhostSplit(ON_TREATMENT, "{\\\"desc\\\" : \\\"this applies only to ON treatment\\\"}"); + map.put(splitAndKey, split); + splitAndKey = new SplitAndKey("other_feature_3", "key_whitelist"); + split = new LocalhostSplit(ON_TREATMENT, null); + map.put(splitAndKey, split); + return map; + } +} \ No newline at end of file diff --git a/client/src/test/java/io/split/client/LocalhostSplitClientTest.java b/client/src/test/java/io/split/client/LocalhostSplitClientTest.java deleted file mode 100644 index b34af8000..000000000 --- a/client/src/test/java/io/split/client/LocalhostSplitClientTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package io.split.client; - -import com.google.common.collect.Maps; -import io.split.grammar.Treatments; -import org.junit.Test; - -import java.util.Map; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -/** - * Tests for LocalhostSplitClient - * - * @author adil - */ -public class LocalhostSplitClientTest { - - @Test - public void defaultsWork() { - Map map = Maps.newHashMap(); - map.put(SplitAndKey.of("onboarding"), LocalhostSplit.of("on")); - map.put(SplitAndKey.of("test"), LocalhostSplit.of("a")); - map.put(SplitAndKey.of("onboarding"), LocalhostSplit.of("off")); // overwrite - - LocalhostSplitClient client = new LocalhostSplitClient(map); - - assertThat(client.getTreatment(null, "foo"), is(equalTo(Treatments.CONTROL))); - assertThat(client.getTreatment("user1", "foo"), is(equalTo(Treatments.CONTROL))); - assertThat(client.getTreatment("user1", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user2", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user1", "test"), is(equalTo("a"))); - assertThat(client.getTreatment("user2", "test"), is(equalTo("a"))); - assertThat(client.getTreatmentWithConfig("user2", "test").config(), is(nullValue())); - assertThat(client.getTreatmentWithConfig("user2", "test").treatment(), is(equalTo("a"))); - } - - @Test - public void overrides_work() { - Map map = Maps.newHashMap(); - map.put(SplitAndKey.of("onboarding"), LocalhostSplit.of("on")); - map.put(SplitAndKey.of("onboarding", "user1"), LocalhostSplit.of("off")); - map.put(SplitAndKey.of("onboarding", "user2"), LocalhostSplit.of("off")); - - LocalhostSplitClient client = new LocalhostSplitClient(map); - - assertThat(client.getTreatment("user1", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user2", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user3", "onboarding"), is(equalTo("on"))); - assertThat(client.getTreatmentWithConfig("user3", "onboarding").config(), is(nullValue())); - assertThat(client.getTreatmentWithConfig("user3", "onboarding").treatment(), is(equalTo("on"))); - } - - @Test - public void if_only_overrides_exist() { - Map map = Maps.newHashMap(); - map.put(SplitAndKey.of("onboarding", "user1"), LocalhostSplit.of("off")); - map.put(SplitAndKey.of("onboarding", "user2"), LocalhostSplit.of("off")); - - LocalhostSplitClient client = new LocalhostSplitClient(map); - - assertThat(client.getTreatment("user1", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user2", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user3", "onboarding"), is(equalTo(Treatments.CONTROL))); - } - - @Test - public void attributes_work() { - Map map = Maps.newHashMap(); - map.put(SplitAndKey.of("onboarding"), LocalhostSplit.of("on")); - map.put(SplitAndKey.of("onboarding", "user1"), LocalhostSplit.of("off")); - map.put(SplitAndKey.of("onboarding", "user2"), LocalhostSplit.of("off")); - - LocalhostSplitClient client = new LocalhostSplitClient(map); - - Map attributes = Maps.newHashMap(); - attributes.put("age", 24); - - assertThat(client.getTreatment("user1", "onboarding", attributes), is(equalTo("off"))); - assertThat(client.getTreatment("user2", "onboarding", attributes), is(equalTo("off"))); - assertThat(client.getTreatment("user3", "onboarding", attributes), is(equalTo("on"))); - } - - @Test - public void update_works() { - Map map = Maps.newHashMap(); - map.put(SplitAndKey.of("onboarding"), LocalhostSplit.of("on")); - map.put(SplitAndKey.of("onboarding", "user1"), LocalhostSplit.of("off")); - map.put(SplitAndKey.of("onboarding", "user2"), LocalhostSplit.of("off")); - - LocalhostSplitClient client = new LocalhostSplitClient(map); - - assertThat(client.getTreatment("user1", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user2", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user3", "onboarding"), is(equalTo("on"))); - - map.clear(); - map.put(SplitAndKey.of("onboarding"), LocalhostSplit.of("on")); - map.put(SplitAndKey.of("onboarding", "user1"), LocalhostSplit.of("off")); - - client.updateFeatureToTreatmentMap(map); - - assertThat(client.getTreatment("user1", "onboarding"), is(equalTo("off"))); - assertThat(client.getTreatment("user2", "onboarding"), is(equalTo("on"))); - assertThat(client.getTreatment("user3", "onboarding"), is(equalTo("on"))); - } -} diff --git a/client/src/test/java/io/split/client/LocalhostSplitFactoryTest.java b/client/src/test/java/io/split/client/LocalhostSplitFactoryTest.java index 63684e8f3..2728c7366 100644 --- a/client/src/test/java/io/split/client/LocalhostSplitFactoryTest.java +++ b/client/src/test/java/io/split/client/LocalhostSplitFactoryTest.java @@ -10,6 +10,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.net.URISyntaxException; import java.util.Map; import static org.hamcrest.Matchers.equalTo; @@ -27,7 +28,7 @@ public class LocalhostSplitFactoryTest { public TemporaryFolder folder = new TemporaryFolder(); @Test - public void works() throws IOException { + public void works() throws IOException, URISyntaxException { File file = folder.newFile(LocalhostSplitFactory.FILENAME); Map map = Maps.newHashMap(); diff --git a/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlCompactSampleTest.java b/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlCompactSampleTest.java index 2319594ce..b54e7f489 100644 --- a/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlCompactSampleTest.java +++ b/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlCompactSampleTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import java.io.IOException; +import java.net.URISyntaxException; import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; @@ -20,7 +21,7 @@ public class LocalhostSplitFactoryYamlCompactSampleTest { @Test - public void works() throws IOException { + public void works() throws IOException, URISyntaxException { String file = getClass().getClassLoader().getResource("split_compact.yaml").getFile(); diff --git a/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlSampleTest.java b/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlSampleTest.java index 390a0b052..933d19039 100644 --- a/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlSampleTest.java +++ b/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlSampleTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import java.io.IOException; +import java.net.URISyntaxException; import java.util.Map; import static org.hamcrest.MatcherAssert.assertThat; @@ -20,7 +21,7 @@ public class LocalhostSplitFactoryYamlSampleTest { @Test - public void works() throws IOException { + public void works() throws IOException, URISyntaxException { String file = getClass().getClassLoader().getResource(SplitClientConfig.LOCALHOST_DEFAULT_FILE).getFile(); diff --git a/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlTest.java b/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlTest.java index 4d68cb030..c0be15838 100644 --- a/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlTest.java +++ b/client/src/test/java/io/split/client/LocalhostSplitFactoryYamlTest.java @@ -12,6 +12,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.StringWriter; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -43,7 +44,7 @@ public class LocalhostSplitFactoryYamlTest { public TemporaryFolder folder = new TemporaryFolder(); @Test - public void works() throws IOException { + public void works() throws IOException, URISyntaxException { File file = folder.newFile(SplitClientConfig.LOCALHOST_DEFAULT_FILE); List> allSplits = new ArrayList();