Skip to content

Commit 30cf55a

Browse files
committed
fix test
1 parent 9f6667c commit 30cf55a

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

client/src/test/java/io/split/client/impressions/UniqueKeysTrackerImpTest.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import org.junit.Test;
88
import org.mockito.Mockito;
99

10+
import java.lang.reflect.Field;
1011
import java.lang.reflect.InvocationTargetException;
1112
import java.lang.reflect.Method;
13+
import java.lang.reflect.Modifier;
1214
import java.util.HashMap;
1315
import java.util.HashSet;
1416
import java.util.List;
@@ -108,30 +110,35 @@ public void testStopSynchronization() throws Exception {
108110
}
109111

110112
@Test
111-
public void testUniqueKeysChunks() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
113+
public void testUniqueKeysChunks() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
112114
UniqueKeysTrackerImp uniqueKeysTrackerImp = new UniqueKeysTrackerImp(_telemetrySynchronizer, 10000, 10000, null);
115+
HashMap<String, HashSet<String>> uniqueKeysHashMap = new HashMap<>();
116+
HashSet<String> feature1 = new HashSet<>();
117+
HashSet<String> feature2 = new HashSet<>();
118+
HashSet<String> feature3 = new HashSet<>();
119+
HashSet<String> feature4 = new HashSet<>();
120+
HashSet<String> feature5 = new HashSet<>();
113121
for (Integer i=1; i<6000; i++) {
114122
if (i <= 1000) {
115-
Assert.assertTrue(uniqueKeysTrackerImp.track("feature1", "key" + i.toString()));
123+
feature1.add("key" + i);
116124
}
117125
if (i <= 2000) {
118-
Assert.assertTrue(uniqueKeysTrackerImp.track("feature2", "key" + i.toString()));
126+
feature2.add("key" + i);
119127
}
120128
if (i <= 3000) {
121-
Assert.assertTrue(uniqueKeysTrackerImp.track("feature3", "key" + i.toString()));
129+
feature3.add("key" + i);
122130
}
123131
if (i <= 4000) {
124-
Assert.assertTrue(uniqueKeysTrackerImp.track("feature4", "key" + i.toString()));
132+
feature4.add("key" + i);
125133
}
126-
Assert.assertTrue(uniqueKeysTrackerImp.track("feature5", "key" + i.toString()));
134+
feature5.add("key" + i);
127135
}
128-
129-
Method methodTrackerSize = uniqueKeysTrackerImp.getClass().getDeclaredMethod("getTrackerKeysSize");
130-
methodTrackerSize.setAccessible(true);
131-
int totalSize = (int) methodTrackerSize.invoke(uniqueKeysTrackerImp);
132-
Assert.assertTrue(totalSize == 15999);
133-
134-
HashMap<String, HashSet<String>> uniqueKeysHashMap = uniqueKeysTrackerImp.popAll();
136+
uniqueKeysHashMap.put("feature1", feature1);
137+
uniqueKeysHashMap.put("feature2", feature2);
138+
uniqueKeysHashMap.put("feature3", feature3);
139+
uniqueKeysHashMap.put("feature4", feature4);
140+
uniqueKeysHashMap.put("feature5", feature5);
141+
135142
List<UniqueKeys.UniqueKey> uniqueKeysFromPopAll = new ArrayList<>();
136143
for (Map.Entry<String, HashSet<String>> uniqueKeyEntry : uniqueKeysHashMap.entrySet()) {
137144
UniqueKeys.UniqueKey uniqueKey = new UniqueKeys.UniqueKey(uniqueKeyEntry.getKey(), new ArrayList<>(uniqueKeyEntry.getValue()));

0 commit comments

Comments
 (0)