11
11
import java .io .IOException ;
12
12
import java .nio .charset .StandardCharsets ;
13
13
import java .util .ArrayList ;
14
+ import java .util .Collections ;
14
15
import java .util .List ;
15
16
import java .util .concurrent .CompletableFuture ;
16
17
import java .util .concurrent .atomic .AtomicInteger ;
@@ -40,11 +41,13 @@ public void testInitialConfigurationFuture() throws IOException {
40
41
41
42
// verify config is empty to start
42
43
assertTrue (configStore .getConfiguration ().isEmpty ());
44
+ assertEquals (Collections .emptySet (), configStore .getConfiguration ().getFlagKeys ());
43
45
Mockito .verify (configStore , Mockito .times (0 )).saveConfiguration (any ());
44
46
45
47
futureConfig .complete (Configuration .builder (flagConfig , false ).build ());
46
48
47
49
assertFalse (configStore .getConfiguration ().isEmpty ());
50
+ assertFalse (configStore .getConfiguration ().getFlagKeys ().isEmpty ());
48
51
Mockito .verify (configStore , Mockito .times (1 )).saveConfiguration (any ());
49
52
assertNotNull (configStore .getConfiguration ().getFlag ("numeric_flag" ));
50
53
}
@@ -69,6 +72,7 @@ public void testInitialConfigurationDoesntClobberFetch() throws IOException {
69
72
requestor .setInitialConfiguration (initialConfigFuture );
70
73
71
74
assertTrue (configStore .getConfiguration ().isEmpty ());
75
+ assertEquals (Collections .emptySet (), configStore .getConfiguration ().getFlagKeys ());
72
76
Mockito .verify (configStore , Mockito .times (0 )).saveConfiguration (any ());
73
77
74
78
// The initial config contains only one flag keyed `numeric_flag`. The fetch response has only
@@ -82,6 +86,7 @@ public void testInitialConfigurationDoesntClobberFetch() throws IOException {
82
86
initialConfigFuture .complete (new Configuration .Builder (flagConfig , false ).build ());
83
87
84
88
assertFalse (configStore .getConfiguration ().isEmpty ());
89
+ assertFalse (configStore .getConfiguration ().getFlagKeys ().isEmpty ());
85
90
Mockito .verify (configStore , Mockito .times (1 )).saveConfiguration (any ());
86
91
87
92
// `numeric_flag` is only in the cache which should have been ignored.
@@ -109,6 +114,7 @@ public void testBrokenFetchDoesntClobberCache() throws IOException {
109
114
requestor .setInitialConfiguration (initialConfigFuture );
110
115
111
116
assertTrue (configStore .getConfiguration ().isEmpty ());
117
+ assertEquals (Collections .emptySet (), configStore .getConfiguration ().getFlagKeys ());
112
118
Mockito .verify (configStore , Mockito .times (0 )).saveConfiguration (any ());
113
119
114
120
requestor .fetchAndSaveFromRemoteAsync ();
@@ -120,6 +126,7 @@ public void testBrokenFetchDoesntClobberCache() throws IOException {
120
126
configFetchFuture .completeExceptionally (new Exception ("Intentional exception" ));
121
127
122
128
assertFalse (configStore .getConfiguration ().isEmpty ());
129
+ assertFalse (configStore .getConfiguration ().getFlagKeys ().isEmpty ());
123
130
Mockito .verify (configStore , Mockito .times (1 )).saveConfiguration (any ());
124
131
125
132
// `numeric_flag` is only in the cache which should be available
@@ -148,6 +155,7 @@ public void testCacheWritesAfterBrokenFetch() throws IOException {
148
155
149
156
// default configuration is empty config.
150
157
assertTrue (configStore .getConfiguration ().isEmpty ());
158
+ assertEquals (Collections .emptySet (), configStore .getConfiguration ().getFlagKeys ());
151
159
152
160
// Fetch from remote with an error
153
161
requestor .fetchAndSaveFromRemoteAsync ();
@@ -159,6 +167,7 @@ public void testCacheWritesAfterBrokenFetch() throws IOException {
159
167
// Verify that a configuration was saved by the requestor
160
168
Mockito .verify (configStore , Mockito .times (1 )).saveConfiguration (any ());
161
169
assertFalse (configStore .getConfiguration ().isEmpty ());
170
+ assertFalse (configStore .getConfiguration ().getFlagKeys ().isEmpty ());
162
171
163
172
// `numeric_flag` is only in the cache which should be available
164
173
assertNotNull (configStore .getConfiguration ().getFlag ("numeric_flag" ));
0 commit comments