Skip to content

Commit 6712220

Browse files
committed
chore: update failing tests
Signed-off-by: Todd Baert <[email protected]>
1 parent f101e2f commit 6712220

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

providers/configcat/src/test/java/dev/openfeature/contrib/providers/configcat/ConfigCatProviderTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ void contextTransformTest() {
218218
String country = "someCountry";
219219
String customPropertyValue = "customProperty_value";
220220
String customPropertyKey = "customProperty";
221+
String targetingKeyKey = "targetingKey";
221222

222223
MutableContext evaluationContext = new MutableContext();
223224
evaluationContext.setTargetingKey(userId);
@@ -227,6 +228,7 @@ void contextTransformTest() {
227228

228229
HashMap<String, Object > customMap = new HashMap<>();
229230
customMap.put(customPropertyKey, customPropertyValue);
231+
customMap.put(targetingKeyKey, userId);
230232
User expectedUser = User.newBuilder().email(email).country(country).custom(customMap).build(userId);
231233
User transformedUser = ContextTransformer.transform(evaluationContext);
232234

providers/statsig/src/test/java/dev/openfeature/contrib/providers/statsig/StatsigProviderTest.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@
4242
*/
4343
class StatsigProviderTest {
4444

45-
public static final String FLAG_NAME = "enabledFeature";
46-
public static final String CONFIG_FLAG_NAME = "alias";
47-
public static final String LAYER_FLAG_NAME = "alias";
48-
public static final String CONFIG_FLAG_VALUE = "test";
49-
public static final String INT_FLAG_NAME = "revision";
50-
public static final String LAYER_INT_FLAG_NAME = "revision";
51-
public static final Integer INT_FLAG_VALUE = 5;
52-
public static final String DOUBLE_FLAG_NAME = "price";
53-
public static final String LAYER_DOUBLE_FLAG_NAME = "price";
54-
public static final Double DOUBLE_FLAG_VALUE = 3.14;
55-
public static final String USERS_FLAG_NAME = "userIdMatching";
56-
public static final String PROPERTIES_FLAG_NAME = "emailMatching";
45+
private static final String FLAG_NAME = "enabledFeature";
46+
private static final String CONFIG_FLAG_NAME = "alias";
47+
private static final String LAYER_FLAG_NAME = "alias";
48+
private static final String CONFIG_FLAG_VALUE = "test";
49+
private static final String INT_FLAG_NAME = "revision";
50+
private static final String LAYER_INT_FLAG_NAME = "revision";
51+
private static final Integer INT_FLAG_VALUE = 5;
52+
private static final String DOUBLE_FLAG_NAME = "price";
53+
private static final String LAYER_DOUBLE_FLAG_NAME = "price";
54+
private static final Double DOUBLE_FLAG_VALUE = 3.14;
55+
private static final String USERS_FLAG_NAME = "userIdMatching";
56+
private static final String PROPERTIES_FLAG_NAME = "emailMatching";
57+
private static final String TARGETING_KEY = "a-targeting-key";
5758
private static StatsigProvider statsigProvider;
5859
private static Client client;
5960

@@ -115,10 +116,10 @@ static void shutdown() {
115116

116117
@Test
117118
void getBooleanEvaluation() {
118-
assertEquals(true, statsigProvider.getBooleanEvaluation(FLAG_NAME, false, new ImmutableContext()).getValue());
119-
assertEquals(true, client.getBooleanValue(FLAG_NAME, false));
120-
assertEquals(false, statsigProvider.getBooleanEvaluation("non-existing", false, new ImmutableContext()).getValue());
121-
assertEquals(false, client.getBooleanValue("non-existing", false));
119+
assertEquals(true, statsigProvider.getBooleanEvaluation(FLAG_NAME, false, new ImmutableContext(TARGETING_KEY)).getValue());
120+
assertEquals(true, client.getBooleanValue(FLAG_NAME, false, new ImmutableContext(TARGETING_KEY)));
121+
assertEquals(false, statsigProvider.getBooleanEvaluation("non-existing", false, new ImmutableContext(TARGETING_KEY)).getValue());
122+
assertEquals(false, client.getBooleanValue("non-existing", false, new ImmutableContext(TARGETING_KEY)));
122123

123124
// expected to succeed when https://github.com/statsig-io/java-server-sdk/issues/22 is resolved and adopted
124125
// assertEquals(true, client.getBooleanValue("non-existing", true));
@@ -128,6 +129,7 @@ void getBooleanEvaluation() {
128129
featureConfig.add("type", "CONFIG");
129130
featureConfig.add("name", "product");
130131
evaluationContext.add("feature_config", featureConfig);
132+
evaluationContext.setTargetingKey(TARGETING_KEY);
131133
assertEquals(true, statsigProvider.getBooleanEvaluation("boolean", false,
132134
evaluationContext).getValue());
133135
}
@@ -139,6 +141,7 @@ void getStringEvaluation() {
139141
featureConfig.add("type", "CONFIG");
140142
featureConfig.add("name", "product");
141143
evaluationContext.add("feature_config", featureConfig);
144+
evaluationContext.setTargetingKey(TARGETING_KEY);
142145
assertEquals(CONFIG_FLAG_VALUE, statsigProvider.getStringEvaluation(CONFIG_FLAG_NAME, "",
143146
evaluationContext).getValue());
144147
assertEquals(CONFIG_FLAG_VALUE, statsigProvider.getStringEvaluation(LAYER_FLAG_NAME, "",
@@ -153,6 +156,7 @@ void getObjectConfigEvaluation() {
153156
featureConfig.add("type", "CONFIG");
154157
featureConfig.add("name", "object-config-name");
155158
evaluationContext.add("feature_config", featureConfig);
159+
evaluationContext.setTargetingKey(TARGETING_KEY);
156160
Value objectEvaluation = statsigProvider.getObjectEvaluation("dummy", new Value("fallback"),
157161
evaluationContext).getValue();
158162

@@ -168,6 +172,7 @@ void getObjectLayerEvaluation() {
168172
featureConfig.add("type", "LAYER");
169173
featureConfig.add("name", "layer-name");
170174
evaluationContext.add("feature_config", featureConfig);
175+
evaluationContext.setTargetingKey(TARGETING_KEY);
171176
Value objectEvaluation = statsigProvider.getObjectEvaluation("dummy", new Value("fallback"),
172177
evaluationContext).getValue();
173178

@@ -184,6 +189,7 @@ void getIntegerEvaluation() {
184189
featureConfig.add("type", "CONFIG");
185190
featureConfig.add("name", "product");
186191
evaluationContext.add("feature_config", featureConfig);
192+
evaluationContext.setTargetingKey(TARGETING_KEY);
187193
assertEquals(INT_FLAG_VALUE, statsigProvider.getIntegerEvaluation(INT_FLAG_NAME, 1,
188194
evaluationContext).getValue());
189195
assertEquals(INT_FLAG_VALUE, statsigProvider.getIntegerEvaluation(LAYER_INT_FLAG_NAME, 1,
@@ -201,6 +207,7 @@ void getDoubleEvaluation() {
201207
featureConfig.add("type", "CONFIG");
202208
featureConfig.add("name", "product");
203209
evaluationContext.add("feature_config", featureConfig);
210+
evaluationContext.setTargetingKey(TARGETING_KEY);
204211
assertEquals(DOUBLE_FLAG_VALUE, statsigProvider.getDoubleEvaluation(DOUBLE_FLAG_NAME, 1.1,
205212
evaluationContext).getValue());
206213
assertEquals(DOUBLE_FLAG_VALUE, statsigProvider.getDoubleEvaluation(LAYER_DOUBLE_FLAG_NAME, 1.1,
@@ -314,6 +321,7 @@ void contextTransformTest() {
314321
String locale = "locale1";
315322
String customPropertyValue = "customProperty_value";
316323
String customPropertyKey = "customProperty";
324+
String targetingKeyKey = "targetingKey";
317325

318326
MutableContext evaluationContext = new MutableContext();
319327
evaluationContext.setTargetingKey(userId);
@@ -331,6 +339,7 @@ void contextTransformTest() {
331339

332340
HashMap<String, String > customMap = new HashMap<>();
333341
customMap.put(customPropertyKey, customPropertyValue);
342+
customMap.put(targetingKeyKey, userId);
334343
StatsigUser expectedUser = new StatsigUser(evaluationContext.getTargetingKey());
335344
expectedUser.setEmail(email);
336345
expectedUser.setCountry(country);

0 commit comments

Comments
 (0)