|
1 | | -// Copyright 2025, Optimizely, Inc. and contributors |
| 1 | +// Copyright 2025, 2026, Optimizely, Inc. and contributors |
2 | 2 | // |
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | // you may not use this file except in compliance with the License. |
@@ -55,8 +55,8 @@ public void setup() { |
55 | 55 | mockCmabClientHelper = spy(new CmabClientHelperAndroid()); |
56 | 56 |
|
57 | 57 | testAttributes = new HashMap<>(); |
58 | | - testAttributes.put("age", 25); |
59 | | - testAttributes.put("country", "US"); |
| 58 | + testAttributes.put("66", 25); |
| 59 | + testAttributes.put("77", "US"); |
60 | 60 | } |
61 | 61 |
|
62 | 62 | @Test |
@@ -309,4 +309,20 @@ public void testRetryConfigurationPassedToClient() { |
309 | 309 | assertEquals("REQUEST_BACKOFF_TIMEOUT should be 1", 1, DefaultCmabClient.REQUEST_BACKOFF_TIMEOUT); |
310 | 310 | assertEquals("REQUEST_RETRIES_POWER should be 1", 1, DefaultCmabClient.REQUEST_RETRIES_POWER); |
311 | 311 | } |
| 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 | + } |
312 | 328 | } |
0 commit comments