@@ -29,6 +29,7 @@ import com.mparticle.mock.MockContext
2929import com.mparticle.mock.MockKitConfiguration
3030import com.mparticle.mock.MockKitManagerImpl
3131import com.mparticle.mock.MockMParticle
32+ import com.mparticle.rokt.PlacementOptions
3233import com.mparticle.rokt.RoktConfig
3334import com.mparticle.rokt.RoktEmbeddedView
3435import com.mparticle.testutils.TestingUtils
@@ -43,10 +44,12 @@ import org.json.JSONException
4344import org.json.JSONObject
4445import org.junit.Assert
4546import org.junit.Assert.assertNull
47+ import org.junit.Assert.assertSame
4648import org.junit.Assert.assertTrue
4749import org.junit.Before
4850import org.junit.Test
4951import org.junit.runner.RunWith
52+ import org.mockito.ArgumentCaptor
5053import org.mockito.ArgumentMatchers.any
5154import org.mockito.Mockito
5255import org.mockito.Mockito.mock
@@ -1848,6 +1851,77 @@ class KitManagerImplTest {
18481851 Assert .assertEquals(" false" , attributes[" sandbox" ])
18491852 }
18501853
1854+ @Test
1855+ fun testRokt_execute_with_PlacementOptions () {
1856+ val mockUser = mock(MParticleUser ::class .java)
1857+ `when `(mockIdentity!! .currentUser).thenReturn(mockUser)
1858+
1859+ val manager: KitManagerImpl = MockKitManagerImpl ()
1860+ val roktListener =
1861+ mock(
1862+ KitIntegration ::class .java,
1863+ withSettings().extraInterfaces(KitIntegration .RoktListener ::class .java),
1864+ )
1865+ `when `(roktListener.isDisabled).thenReturn(false )
1866+ manager.providers =
1867+ ConcurrentHashMap <Int , KitIntegration >().apply {
1868+ put(1 , roktListener)
1869+ }
1870+
1871+ val attributes = hashMapOf<String , String >()
1872+ val placementOptions = PlacementOptions (integrationStartTimestamp = 123L )
1873+
1874+ manager.execute(" Test" , attributes, null , null , null , null , placementOptions)
1875+
1876+ val optionsCaptor = ArgumentCaptor .forClass(PlacementOptions ::class .java)
1877+ verify(roktListener as KitIntegration .RoktListener ).execute(
1878+ any(),
1879+ any(),
1880+ any(),
1881+ any(),
1882+ any(),
1883+ any(),
1884+ any(),
1885+ optionsCaptor.capture(),
1886+ )
1887+ assertSame(placementOptions, optionsCaptor.value)
1888+ }
1889+
1890+ @Test
1891+ fun testRokt_execute_without_PlacementOptions () {
1892+ val mockUser = mock(MParticleUser ::class .java)
1893+ `when `(mockIdentity!! .currentUser).thenReturn(mockUser)
1894+
1895+ val manager: KitManagerImpl = MockKitManagerImpl ()
1896+ val roktListener =
1897+ mock(
1898+ KitIntegration ::class .java,
1899+ withSettings().extraInterfaces(KitIntegration .RoktListener ::class .java),
1900+ )
1901+ `when `(roktListener.isDisabled).thenReturn(false )
1902+ manager.providers =
1903+ ConcurrentHashMap <Int , KitIntegration >().apply {
1904+ put(1 , roktListener)
1905+ }
1906+
1907+ val attributes = hashMapOf<String , String >()
1908+
1909+ manager.execute(" Test" , attributes, null , null , null , null )
1910+
1911+ val optionsCaptor = ArgumentCaptor .forClass(PlacementOptions ::class .java)
1912+ verify(roktListener as KitIntegration .RoktListener ).execute(
1913+ any(),
1914+ any(),
1915+ any(),
1916+ any(),
1917+ any(),
1918+ any(),
1919+ any(),
1920+ optionsCaptor.capture(),
1921+ )
1922+ assertNull(optionsCaptor.value)
1923+ }
1924+
18511925 @Test
18521926 fun testRokt_SandboxMode_When_Environment_IS_Development () {
18531927 val sideloadedKit = mock(MPSideloadedKit ::class .java)
@@ -2265,6 +2339,19 @@ class KitManagerImplTest {
22652339 Logger .info(" Executed with $attributes " )
22662340 }
22672341
2342+ override fun execute (
2343+ viewName : String ,
2344+ attributes : MutableMap <String , String >,
2345+ mpRoktEventCallback : MpRoktEventCallback ? ,
2346+ placeHolders : MutableMap <String , WeakReference <RoktEmbeddedView >>? ,
2347+ fontTypefaces : MutableMap <String , WeakReference <Typeface >>? ,
2348+ user : FilteredMParticleUser ? ,
2349+ config : RoktConfig ? ,
2350+ options : PlacementOptions ? ,
2351+ ) {
2352+ Logger .info(" Executed with $attributes and options $options " )
2353+ }
2354+
22682355 override fun events (identifier : String ): Flow <RoktEvent > {
22692356 Logger .info(" events called with identfier: $identifier " )
22702357 return flowOf()
0 commit comments