|
25 | 25 | import com.optimizely.ab.android.odp.ODPEventClient; |
26 | 26 | import com.optimizely.ab.android.odp.ODPSegmentClient; |
27 | 27 | import com.optimizely.ab.android.odp.VuidManager; |
| 28 | +import com.optimizely.ab.android.sdk.cmab.CmabClientHelperAndroid; |
28 | 29 | import com.optimizely.ab.android.sdk.cmab.DefaultCmabClient; |
29 | 30 | import com.optimizely.ab.android.shared.Client; |
30 | 31 | import com.optimizely.ab.android.shared.DatafileConfig; |
|
43 | 44 | import com.optimizely.ab.odp.ODPSegmentManager; |
44 | 45 |
|
45 | 46 | import org.junit.After; |
| 47 | +import org.junit.Assert; |
46 | 48 | import org.junit.Before; |
47 | 49 | import org.junit.Test; |
48 | 50 | import org.junit.runner.RunWith; |
@@ -544,7 +546,52 @@ public void testCmabServiceConfigurationValidation() throws Exception { |
544 | 546 |
|
545 | 547 | assertNotNull("Manager should be created successfully", manager); |
546 | 548 | } |
547 | | - |
| 549 | +// |
| 550 | +// @Test |
| 551 | +// public void testCmabServiceConfigurationValidation_2() throws Exception { |
| 552 | +// // Custom configuration for cmab endpoint |
| 553 | +// String customCmabEndpoint = "https://google.com"; |
| 554 | +// |
| 555 | +// // Mock the builder and its static method |
| 556 | +// |
| 557 | +// DefaultCmabService.Builder mockBuilder = getMockDefaultCmabServiceBuilder(); |
| 558 | +// mockStatic(DefaultCmabService.class); |
| 559 | +// when(DefaultCmabService.builder()).thenReturn(mockBuilder); |
| 560 | +// DefaultCmabService mockDefaultCmabService = mock(DefaultCmabService.class); |
| 561 | +// when(mockBuilder.build()).thenReturn(mockDefaultCmabService); |
| 562 | +// |
| 563 | +// // Prevent the real OptimizelyManager from being constructed |
| 564 | +// whenNew(OptimizelyManager.class).withAnyArguments().thenReturn(mock(OptimizelyManager.class)); |
| 565 | +// |
| 566 | +// // Spy on the real DefaultCmabClient constructor. |
| 567 | +// |
| 568 | +// final DefaultCmabClient[] clientSpyContainer = new DefaultCmabClient[1]; |
| 569 | +// whenNew(DefaultCmabClient.class).withAnyArguments().thenAnswer(invocation -> { |
| 570 | +// // Create a REAL spy of the object that was about to be created. |
| 571 | +// DefaultCmabClient realClient = (DefaultCmabClient) invocation.callRealMethod(); |
| 572 | +// DefaultCmabClient clientSpy = spy(realClient); |
| 573 | +// clientSpyContainer[0] = clientSpy; // Store the spy in a container to access it later |
| 574 | +// return clientSpy; |
| 575 | +// }); |
| 576 | +// |
| 577 | +// // Build the manager with the custom endpoint |
| 578 | +// |
| 579 | +// OptimizelyManager manager = OptimizelyManager.builder(testProjectId) |
| 580 | +// .withCmabPredictionEndpoint(customCmabEndpoint) |
| 581 | +// .build(mockContext); |
| 582 | +// |
| 583 | +// // Assert |
| 584 | +// |
| 585 | +// DefaultCmabClient capturedClient = clientSpyContainer[0]; |
| 586 | +// assertNotNull("The DefaultCmabClient spy should have been captured", capturedClient); |
| 587 | +// |
| 588 | +// CmabClientHelperAndroid helper = capturedClient.getCmabClientHelper(); |
| 589 | +// Assert.assertEquals("The helper endpoint should have been updated", customCmabEndpoint, helper.getCmabPredictionEndpoint()); |
| 590 | +// |
| 591 | +// verify(mockBuilder).withClient(eq(capturedClient)); |
| 592 | +// verify(mockBuilder).build(); |
| 593 | +// } |
| 594 | +// |
548 | 595 | @Test |
549 | 596 | public void testCmabServiceDefaultConfigurationValidation() throws Exception { |
550 | 597 | // Default configuration values |
|
0 commit comments