Skip to content

Commit 41d30c1

Browse files
authored
[AI-FSSDK] [FSSDK-12750] Use attribute id instead of key for CMAB predictions (#536)
* [AI-FSSDK] [FSSDK-12750] Use attribute id instead of key for CMAB predictions * [FSSDK-12750] Fix core-api version to 4.4.2
1 parent f82c5f9 commit 41d30c1

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

android-sdk/src/test/java/com/optimizely/ab/android/sdk/cmab/DefaultCmabClientTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025, Optimizely, Inc. and contributors
1+
// Copyright 2025, 2026, Optimizely, Inc. and contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -55,8 +55,8 @@ public void setup() {
5555
mockCmabClientHelper = spy(new CmabClientHelperAndroid());
5656

5757
testAttributes = new HashMap<>();
58-
testAttributes.put("age", 25);
59-
testAttributes.put("country", "US");
58+
testAttributes.put("66", 25);
59+
testAttributes.put("77", "US");
6060
}
6161

6262
@Test
@@ -309,4 +309,20 @@ public void testRetryConfigurationPassedToClient() {
309309
assertEquals("REQUEST_BACKOFF_TIMEOUT should be 1", 1, DefaultCmabClient.REQUEST_BACKOFF_TIMEOUT);
310310
assertEquals("REQUEST_RETRIES_POWER should be 1", 1, DefaultCmabClient.REQUEST_RETRIES_POWER);
311311
}
312+
313+
@Test
314+
public void testBuildRequestJsonUsesAttributeIds() {
315+
CmabClientHelperAndroid helper = new CmabClientHelperAndroid();
316+
Map<String, Object> attributes = new HashMap<>();
317+
attributes.put("66", 25);
318+
attributes.put("77", "US");
319+
320+
String json = helper.buildRequestJson("user123", "exp1", attributes, "uuid-123");
321+
322+
assertTrue(json.contains("\"id\":\"66\""));
323+
assertTrue(json.contains("\"id\":\"77\""));
324+
assertTrue(json.contains("\"type\":\"custom_attribute\""));
325+
assertFalse(json.contains("\"id\":\"age\""));
326+
assertFalse(json.contains("\"id\":\"country\""));
327+
}
312328
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016-2021, Optimizely, Inc. and contributors *
2+
* Copyright 2016-2021, 2026, Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *

0 commit comments

Comments
 (0)