Skip to content
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

Flag sets #547

Merged
merged 115 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
a896f6d
Modify flags DTO & manager object (#522)
gthea Aug 23, 2023
b18bbb8
Sets validator; BY_SET filter
gthea Aug 23, 2023
5561a3b
Add validator log
gthea Aug 23, 2023
4845a6c
Fix regex
gthea Aug 23, 2023
35f6e99
Fix name
gthea Aug 23, 2023
421a4aa
Sets in filter builder
gthea Aug 24, 2023
ece6c42
Add comment
gthea Aug 24, 2023
be35589
Pre work
gthea Aug 28, 2023
60b5781
Modified version
gthea Aug 28, 2023
22c4e70
Fixes
gthea Aug 28, 2023
63870bf
Remove unnecesary builder structure
gthea Aug 28, 2023
4f22c8f
Remove line
gthea Aug 28, 2023
6f1dc64
Sets in storage
gthea Aug 28, 2023
8d2e1a9
WIP
gthea Aug 28, 2023
ea248ea
Improve tests
gthea Aug 28, 2023
04fb6c2
FIx
gthea Aug 28, 2023
97c61d4
Sets validator fixes (#523)
gthea Aug 29, 2023
473ebad
Sets validator (#523)
gthea Aug 29, 2023
c67a6d7
Sets in FilterBuilder (#524)
gthea Aug 29, 2023
25dad00
Sets in processor
gthea Aug 29, 2023
47aadb3
Modify cache filtering task (#525)
gthea Aug 29, 2023
27caf6f
Rename properties for readability
gthea Aug 30, 2023
e0c34c3
Rename methods
gthea Aug 30, 2023
f16ec4a
Simplify comment
gthea Aug 30, 2023
6cd4a44
Move some logicto helper
gthea Aug 30, 2023
1bbfd93
Sets cache in memory storage (#526)
gthea Aug 30, 2023
b17c4a1
PR Fixes (#527)
gthea Aug 30, 2023
c029304
Fix
gthea Aug 30, 2023
34b83e6
Clear cache on filter change
gthea Aug 30, 2023
052f774
Fix name
gthea Aug 30, 2023
3837f8f
Non retryable task
gthea Aug 31, 2023
535f7b5
Evaluation by sets in SplitClient interface
gthea Sep 1, 2023
53c5f2a
Process changes according to sets (#528)
gthea Sep 1, 2023
d1cf035
Clear cache on filter change (#529)
gthea Sep 1, 2023
7c5cd23
Prevent retry in specific tasks (#530)
gthea Sep 1, 2023
0ae7326
Setup for new client methods
gthea Sep 1, 2023
b2cf688
Fixes
gthea Sep 1, 2023
135e3e4
treatments by flag set
gthea Sep 1, 2023
ff1d93e
Test
gthea Sep 1, 2023
1232ed6
More tests
gthea Sep 1, 2023
b327ce7
WIP treatment multiple sets
gthea Sep 4, 2023
ec59529
Tests for multiple set evaluation
gthea Sep 4, 2023
d655538
Improvement
gthea Sep 4, 2023
8ef9ed1
Tests
gthea Sep 4, 2023
4eaaa30
Add warning log
gthea Sep 4, 2023
56bd11a
Readability changes
gthea Sep 4, 2023
7e9453c
New client methods groundwork (#531)
gthea Sep 4, 2023
ca511ac
Fix latency logic
gthea Sep 4, 2023
1ba11e3
Sets evaluation in clients
gthea Sep 4, 2023
894d98a
New treatment methods telemetry
gthea Sep 5, 2023
b6592e6
More treatment manager tests;
gthea Sep 5, 2023
a41f7db
Fix json key
gthea Sep 5, 2023
705a281
Sets config telemetry
gthea Sep 6, 2023
d873f04
Treatments by set in treatment manager (#532)
gthea Sep 6, 2023
c9662a3
Fix fst count
gthea Sep 6, 2023
844452d
byName & bySet processing of changes
gthea Sep 6, 2023
9b0e8fc
Flag processing strategies
gthea Sep 6, 2023
bba3517
Fix
gthea Sep 7, 2023
9700043
Sets evaluation in clients (#533)
gthea Sep 7, 2023
bb66c9f
Telemetry for new evaluation methods (#534)
gthea Sep 7, 2023
beb3d47
Remove unnecessary param
gthea Sep 7, 2023
a0b9a08
Fix
gthea Sep 7, 2023
d41b6ea
Fix test; remove duplicated code
gthea Sep 7, 2023
eafcc26
Sets config telemetry (#535)
gthea Sep 7, 2023
9820f65
Refactor internal filter tracking to use a Map
gthea Sep 7, 2023
0b9f116
Fix test
gthea Sep 7, 2023
13cae88
Cleanup
gthea Sep 8, 2023
b7c77fa
Discard sets that are not configured; do not process according to fil…
gthea Sep 8, 2023
78070d1
Refactor internal filter tracking to use a Map
gthea Sep 7, 2023
a0359e8
Fix test
gthea Sep 7, 2023
1b7004c
Cleanup
gthea Sep 8, 2023
77a894a
WIP tests
gthea Sep 8, 2023
ec40928
Streaming test setup
gthea Sep 11, 2023
15175ec
First streaming test
gthea Sep 11, 2023
81f54ce
Merge branch 'filter_grouping_refactor' into SDKS-7478_1
gthea Sep 11, 2023
55c18bb
More tests
gthea Sep 11, 2023
b70e895
More tests
gthea Sep 11, 2023
67e32c0
Fix test
gthea Sep 11, 2023
9ee4b34
Kill test
gthea Sep 11, 2023
406463b
By name filter in feature flag processor (#536)
gthea Sep 12, 2023
375f8f6
Filter grouping refactor (#537)
gthea Sep 12, 2023
fd70600
Functionality fixes (#538)
gthea Sep 12, 2023
7138fcb
Kill test 2
gthea Sep 12, 2023
a16d8f4
Kill task improvement
gthea Sep 12, 2023
6ecc1a5
Sets evaluation test
gthea Sep 12, 2023
ea49ea0
Fix test
gthea Sep 12, 2023
14b3116
Refactor
gthea Sep 12, 2023
b9c31b1
Better comments
gthea Sep 12, 2023
e59ed36
Merge branch 'SDKS-7478_1' into SDKS-7478_2
gthea Sep 12, 2023
3168519
Minify json
gthea Sep 13, 2023
a3f4925
Merge branch 'SDKS-7478_1' into SDKS-7478_2
gthea Sep 13, 2023
b609962
Merge branch 'SDKS-7440' into SDKS-7478_1
gthea Sep 13, 2023
95c88ee
Fix name
gthea Sep 13, 2023
7c8cc4d
Merge branch 'SDKS-7478_1' into SDKS-7478_2
gthea Sep 13, 2023
d2d8800
Track invalid values in SyncConfig
gthea Sep 13, 2023
67f14d6
Sets in telemetry config test
gthea Sep 13, 2023
3b3caa6
Evaluation with flags tests in telemetry;
gthea Sep 13, 2023
bf8bca2
Extra safety check
gthea Sep 13, 2023
ba26ccd
Additional query string test
gthea Sep 14, 2023
74d4d2a
FlagSetsFilter
gthea Sep 14, 2023
5e34963
Sets synchronization tests (#539)
gthea Sep 14, 2023
ef47f73
Sets evaluation tests (#540)
gthea Sep 14, 2023
776e30b
Sets telemetry tests (#541)
gthea Sep 14, 2023
0bedb89
Flag sets filter initial integration
gthea Sep 14, 2023
bf91a01
Update tests
gthea Sep 14, 2023
e350d67
Merge branch 'SDKS-7440' into SDKS-7511
gthea Sep 14, 2023
ef81e36
Fix test
gthea Sep 14, 2023
9c284d7
Filter integration
gthea Sep 15, 2023
ee1d73c
Refactor
gthea Sep 15, 2023
5e93c2d
FlagSetsFilter component (#542)
gthea Sep 21, 2023
f00e6b2
Add filter types conflict log message (#543)
gthea Sep 27, 2023
f3029a6
Default treatment in SplitView (#545)
gthea Oct 18, 2023
2d1147d
Fix sets counters for telemetry (#546)
gthea Oct 18, 2023
b671826
Post review changes (#548)
gthea Oct 27, 2023
98b7069
Update version (#549)
gthea Oct 30, 2023
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
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply plugin: 'signing'
apply plugin: 'kotlin-android'

ext {
splitVersion = '3.3.1-alpha-1'
splitVersion = '3.4.0-alpha-1'
}

android {
Expand Down Expand Up @@ -225,6 +225,7 @@ afterEvaluate {
release(MavenPublication) {
from components.release

artifactId = 'android-client'
groupId = 'io.split.client'
version = splitVersion
artifact sourcesJar
Expand All @@ -241,6 +242,7 @@ afterEvaluate {
development(MavenPublication) {
from components.release

artifactId = 'android-client'
groupId = 'io.split.client'
version = splitVersion
artifact sourcesJar
Expand Down
1 change: 1 addition & 0 deletions src/androidTest/assets/split_changes_flag_set-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"splits":[{"trafficTypeName":"client","name":"workm","trafficAllocation":100,"trafficAllocationSeed":147392224,"seed":524417105,"status":"ACTIVE","killed":false,"defaultTreatment":"on","changeNumber":1602798638344,"algo":2,"configurations":{},"sets":["set_3"],"conditions":[{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"IN_SEGMENT","negate":false,"userDefinedSegmentMatcherData":{"segmentName":"new_segment"},"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":0},{"treatment":"off","size":0},{"treatment":"free","size":100},{"treatment":"conta","size":0}],"label":"in segment new_segment"},{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"ALL_KEYS","negate":false,"userDefinedSegmentMatcherData":null,"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":100},{"treatment":"off","size":0},{"treatment":"free","size":0},{"treatment":"conta","size":0}],"label":"default rule"}]}],"since":1602797638344,"till":1602798638344}
1 change: 1 addition & 0 deletions src/androidTest/assets/split_changes_flag_set-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"splits":[{"trafficTypeName":"client","name":"workm","trafficAllocation":100,"trafficAllocationSeed":147392224,"seed":524417105,"status":"ACTIVE","killed":false,"defaultTreatment":"on","changeNumber":1602797638344,"algo":2,"configurations":{},"sets":["set_1"],"conditions":[{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"IN_SEGMENT","negate":false,"userDefinedSegmentMatcherData":{"segmentName":"new_segment"},"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":0},{"treatment":"off","size":0},{"treatment":"free","size":100},{"treatment":"conta","size":0}],"label":"in segment new_segment"},{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"ALL_KEYS","negate":false,"userDefinedSegmentMatcherData":null,"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":100},{"treatment":"off","size":0},{"treatment":"free","size":0},{"treatment":"conta","size":0}],"label":"default rule"}]}],"since":1602796638344,"till":1602797638344}
1 change: 1 addition & 0 deletions src/androidTest/assets/split_changes_flag_set-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"splits":[{"trafficTypeName":"client","name":"workm","trafficAllocation":100,"trafficAllocationSeed":147392224,"seed":524417105,"status":"ACTIVE","killed":false,"defaultTreatment":"on","changeNumber":1602796638344,"algo":2,"configurations":{},"sets":["set_1","set_2"],"conditions":[{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"IN_SEGMENT","negate":false,"userDefinedSegmentMatcherData":{"segmentName":"new_segment"},"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":0},{"treatment":"off","size":0},{"treatment":"free","size":100},{"treatment":"conta","size":0}],"label":"in segment new_segment"},{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"ALL_KEYS","negate":false,"userDefinedSegmentMatcherData":null,"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":100},{"treatment":"off","size":0},{"treatment":"free","size":0},{"treatment":"conta","size":0}],"label":"default rule"}]},{"trafficTypeName":"client","name":"workm_set_3","trafficAllocation":100,"trafficAllocationSeed":147392224,"seed":524417105,"status":"ACTIVE","killed":false,"defaultTreatment":"on","changeNumber":1602796638344,"algo":2,"configurations":{},"sets":["set_3"],"conditions":[{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"IN_SEGMENT","negate":false,"userDefinedSegmentMatcherData":{"segmentName":"new_segment"},"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":0},{"treatment":"off","size":0},{"treatment":"free","size":100},{"treatment":"conta","size":0}],"label":"in segment new_segment"},{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"client","attribute":null},"matcherType":"ALL_KEYS","negate":false,"userDefinedSegmentMatcherData":null,"whitelistMatcherData":null,"unaryNumericMatcherData":null,"betweenMatcherData":null,"booleanMatcherData":null,"dependencyMatcherData":null,"stringMatcherData":null}]},"partitions":[{"treatment":"on","size":100},{"treatment":"off","size":0},{"treatment":"free","size":0},{"treatment":"conta","size":0}],"label":"default rule"}]}],"since":-1,"till":1602796638344}
20 changes: 20 additions & 0 deletions src/androidTest/java/fake/SplitClientStub.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ public Map<String, SplitResult> getTreatmentsWithConfig(List<String> featureFlag
return null;
}

@Override
public Map<String, String> getTreatmentsByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes) {
return null;
}

@Override
public Map<String, String> getTreatmentsByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes) {
return null;
}

@Override
public Map<String, SplitResult> getTreatmentsWithConfigByFlagSet(@NonNull String flagSet, @Nullable Map<String, Object> attributes) {
return null;
}

@Override
public Map<String, SplitResult> getTreatmentsWithConfigByFlagSets(@NonNull List<String> flagSets, @Nullable Map<String, Object> attributes) {
return null;
}

@Override
public void destroy() {

Expand Down
5 changes: 0 additions & 5 deletions src/androidTest/java/fake/SynchronizerSpyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public void loadAndSynchronizeSplits() {
mSynchronizer.loadAndSynchronizeSplits();
}

@Override
public void loadSplitsFromCache() {
mSynchronizer.loadSplitsFromCache();
}

@Override
public void loadMySegmentsFromCache() {
mSynchronizer.loadMySegmentsFromCache();
Expand Down
30 changes: 18 additions & 12 deletions src/androidTest/java/helper/IntegrationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;

import androidx.annotation.Nullable;
import androidx.core.util.Pair;

import com.google.common.base.Strings;
Expand All @@ -16,6 +17,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;

import fake.HttpClientMock;
import fake.HttpResponseMock;
Expand Down Expand Up @@ -257,30 +259,36 @@ public static String splitChangeV2CompressionType0() {
"eyJ0cmFmZmljVHlwZU5hbWUiOiJ1c2VyIiwiaWQiOiJkNDMxY2RkMC1iMGJlLTExZWEtOGE4MC0xNjYwYWRhOWNlMzkiLCJuYW1lIjoibWF1cm9famF2YSIsInRyYWZmaWNBbGxvY2F0aW9uIjoxMDAsInRyYWZmaWNBbGxvY2F0aW9uU2VlZCI6LTkyMzkxNDkxLCJzZWVkIjotMTc2OTM3NzYwNCwic3RhdHVzIjoiQUNUSVZFIiwia2lsbGVkIjpmYWxzZSwiZGVmYXVsdFRyZWF0bWVudCI6Im9mZiIsImNoYW5nZU51bWJlciI6MTY4NDMyOTg1NDM4NSwiYWxnbyI6MiwiY29uZmlndXJhdGlvbnMiOnt9LCJjb25kaXRpb25zIjpbeyJjb25kaXRpb25UeXBlIjoiV0hJVEVMSVNUIiwibWF0Y2hlckdyb3VwIjp7ImNvbWJpbmVyIjoiQU5EIiwibWF0Y2hlcnMiOlt7Im1hdGNoZXJUeXBlIjoiV0hJVEVMSVNUIiwibmVnYXRlIjpmYWxzZSwid2hpdGVsaXN0TWF0Y2hlckRhdGEiOnsid2hpdGVsaXN0IjpbImFkbWluIiwibWF1cm8iLCJuaWNvIl19fV19LCJwYXJ0aXRpb25zIjpbeyJ0cmVhdG1lbnQiOiJvZmYiLCJzaXplIjoxMDB9XSwibGFiZWwiOiJ3aGl0ZWxpc3RlZCJ9LHsiY29uZGl0aW9uVHlwZSI6IlJPTExPVVQiLCJtYXRjaGVyR3JvdXAiOnsiY29tYmluZXIiOiJBTkQiLCJtYXRjaGVycyI6W3sia2V5U2VsZWN0b3IiOnsidHJhZmZpY1R5cGUiOiJ1c2VyIn0sIm1hdGNoZXJUeXBlIjoiSU5fU0VHTUVOVCIsIm5lZ2F0ZSI6ZmFsc2UsInVzZXJEZWZpbmVkU2VnbWVudE1hdGNoZXJEYXRhIjp7InNlZ21lbnROYW1lIjoibWF1ci0yIn19XX0sInBhcnRpdGlvbnMiOlt7InRyZWF0bWVudCI6Im9uIiwic2l6ZSI6MH0seyJ0cmVhdG1lbnQiOiJvZmYiLCJzaXplIjoxMDB9LHsidHJlYXRtZW50IjoiVjQiLCJzaXplIjowfSx7InRyZWF0bWVudCI6InY1Iiwic2l6ZSI6MH1dLCJsYWJlbCI6ImluIHNlZ21lbnQgbWF1ci0yIn0seyJjb25kaXRpb25UeXBlIjoiUk9MTE9VVCIsIm1hdGNoZXJHcm91cCI6eyJjb21iaW5lciI6IkFORCIsIm1hdGNoZXJzIjpbeyJrZXlTZWxlY3RvciI6eyJ0cmFmZmljVHlwZSI6InVzZXIifSwibWF0Y2hlclR5cGUiOiJBTExfS0VZUyIsIm5lZ2F0ZSI6ZmFsc2V9XX0sInBhcnRpdGlvbnMiOlt7InRyZWF0bWVudCI6Im9uIiwic2l6ZSI6MH0seyJ0cmVhdG1lbnQiOiJvZmYiLCJzaXplIjoxMDB9LHsidHJlYXRtZW50IjoiVjQiLCJzaXplIjowfSx7InRyZWF0bWVudCI6InY1Iiwic2l6ZSI6MH1dLCJsYWJlbCI6ImRlZmF1bHQgcnVsZSJ9XX0=");
}

private static String splitChangeV2(String changeNumber, String previousChangeNumber, String compressionType, String compressedPayload) {
public static String splitChangeV2(String changeNumber, String previousChangeNumber, String compressionType, String compressedPayload) {
return "id: vQQ61wzBRO:0:0\n" +
"event: message\n" +
"data: {\"id\":\"m2T85LA4fQ:0:0\",\"clientId\":\"pri:NzIyNjY1MzI4\",\"timestamp\":"+System.currentTimeMillis()+",\"encoding\":\"json\",\"channel\":\"NzM2MDI5Mzc0_MTgyNTg1MTgwNg==_splits\",\"data\":\"{\\\"type\\\":\\\"SPLIT_UPDATE\\\",\\\"changeNumber\\\":"+changeNumber+",\\\"pcn\\\":"+previousChangeNumber+",\\\"c\\\":"+compressionType+",\\\"d\\\":\\\""+compressedPayload+"\\\"}\"}\n";
}

public static String splitKill(String changeNumber, String splitName) {
return "id:cf74eb42-f687-48e4-ad18-af2125110aac\n" +
"event:message\n" +
"data:{\"id\":\"-OT-rGuSwz:0:0\",\"clientId\":\"NDEzMTY5Mzg0MA==:NDIxNjU0NTUyNw==\",\"timestamp\":"+System.currentTimeMillis()+",\"encoding\":\"json\",\"channel\":\"NzM2MDI5Mzc0_MTgyNTg1MTgwNg==_splits\",\"data\":\"{\\\"type\\\":\\\"SPLIT_KILL\\\",\\\"changeNumber\\\":" + changeNumber + ",\\\"defaultTreatment\\\":\\\"off\\\",\\\"splitName\\\":\\\"" + splitName + "\\\"}\"}\n";
}

/**
* Builds a dispatcher with the given responses.
*
* @param responses The responses to be returned by the dispatcher. The keys are url paths.
* @return The dispatcher to be used in {@link HttpClientMock}
*/
public static HttpResponseMockDispatcher buildDispatcher(Map<String, ResponseClosure> responses) {
return buildDispatcher(responses, Collections.emptyMap());
return buildDispatcher(responses, null);
}

/**
* Builds a dispatcher with the given responses.
*
* @param responses The responses to be returned by the dispatcher. The keys are url paths.
* @param streamingResponses The streaming responses to be returned by the dispatcher. The keys are url paths.
* @param streamingQueue The streaming responses to be returned by the dispatcher.
* @return The dispatcher to be used in {@link HttpClientMock}
*/
public static HttpResponseMockDispatcher buildDispatcher(Map<String, ResponseClosure> responses, Map<String, StreamingResponseClosure> streamingResponses) {
public static HttpResponseMockDispatcher buildDispatcher(Map<String, ResponseClosure> responses, @Nullable BlockingQueue<String> streamingQueue) {
return new HttpResponseMockDispatcher() {
@Override
public HttpResponseMock getResponse(URI uri, HttpMethod method, String body) {
Expand All @@ -300,17 +308,11 @@ public HttpResponseMock getResponse(URI uri, HttpMethod method, String body) {
@Override
public HttpStreamResponseMock getStreamResponse(URI uri) {
try {
String path = uri.getPath().replace("/api/", "");
if (streamingResponses.containsKey(path)) {
return streamingResponses.get(path).onResponse(uri);
} else {
return new HttpStreamResponseMock(200, null);
}
return new HttpStreamResponseMock(200, streamingQueue);
} catch (IOException e) {
e.printStackTrace();
return null;
}

return null;
}
};
}
Expand All @@ -322,6 +324,10 @@ public interface ResponseClosure {
HttpResponseMock onResponse(URI uri,
HttpMethod httpMethod,
String body);

static String getSinceFromUri(URI uri) {
return uri.getQuery().split("&")[0].split("=")[1];
}
}

/**
Expand Down
Loading