|
44 | 44 | import org.junit.Before;
|
45 | 45 | import org.junit.Test;
|
46 | 46 | import org.junit.runner.RunWith;
|
| 47 | +import org.mockito.ArgumentCaptor; |
47 | 48 | import org.mockito.runners.MockitoJUnitRunner;
|
48 | 49 | import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
49 | 50 | import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
69 | 70 | import static org.powermock.api.mockito.PowerMockito.whenNew;
|
70 | 71 |
|
71 | 72 | import java.sql.Time;
|
| 73 | +import java.util.Map; |
72 | 74 | import java.util.concurrent.TimeUnit;
|
73 | 75 |
|
74 | 76 | @RunWith(PowerMockRunner.class)
|
@@ -369,4 +371,33 @@ public void testBuildWithODP_customSegmentFetchTimeout() throws Exception {
|
369 | 371 | assertEquals(ODPEventClient.Companion.getCONNECTION_TIMEOUT(), 30*1000);
|
370 | 372 | }
|
371 | 373 |
|
| 374 | + @Test |
| 375 | + public void testBuildWithODP_defaultCommonDataAndIdentifiers() throws Exception { |
| 376 | + ODPEventManager mockEventManager = mock(ODPEventManager.class); |
| 377 | + whenNew(ODPEventManager.class).withAnyArguments().thenReturn(mockEventManager); |
| 378 | + whenNew(ODPSegmentManager.class).withAnyArguments().thenReturn(mock(ODPSegmentManager.class)); |
| 379 | + whenNew(ODPManager.class).withAnyArguments().thenReturn(mock(ODPManager.class)); |
| 380 | + |
| 381 | + OptimizelyManager manager = OptimizelyManager.builder() |
| 382 | + .withSDKKey(testSdkKey) |
| 383 | + .withVuid("test-vuid") |
| 384 | + .build(mockContext); |
| 385 | + |
| 386 | + ArgumentCaptor<Map<String, Object>> captorData = ArgumentCaptor.forClass(Map.class); |
| 387 | + ArgumentCaptor<Map<String, String>> captorIdentifiers = ArgumentCaptor.forClass(Map.class); |
| 388 | + |
| 389 | + verify(mockEventManager).setUserCommonData(captorData.capture()); |
| 390 | + verify(mockEventManager).setUserCommonIdentifiers(captorIdentifiers.capture()); |
| 391 | + |
| 392 | + Map<String, Object> data = captorData.getValue(); |
| 393 | + Map<String, String> identifiers = captorIdentifiers.getValue(); |
| 394 | + |
| 395 | + // here we just validate if data is passed or not (all values are validated in other tests: OptimizelyDefaultAttributesTest) |
| 396 | + assertEquals(data.get("os"), "Android"); |
| 397 | + assertEquals(data.size(), 4); |
| 398 | + |
| 399 | + assertEquals(identifiers.get("vuid"), "test-vuid"); |
| 400 | + assertEquals(identifiers.size(), 1); |
| 401 | + } |
| 402 | + |
372 | 403 | }
|
0 commit comments