@Test public void testCoreCallbacksImpl() { RandomUtils randomUtils = new RandomUtils(); Random ran = new Random(); ConfigManager mockConfigManager = Mockito.mock(ConfigManager.class); AppStateManager mockAppStateManager = Mockito.mock(AppStateManager.class); Activity mockActivity = Mockito.mock(Activity.class); JSONArray mockKitConfiguration = new JSONArray(); for (int i = 0; i < randomUtils.randomInt(1, 10); i++) { mockKitConfiguration.put(randomUtils.getAlphaNumericString(randomUtils.randomInt(1, 30))); } Uri mockLaunchUri = Mockito.mock(Uri.class); String mockPushInstanceId = randomUtils.getAlphaNumericString(15); String mockPushSenderId = randomUtils.getAlphaNumericString(10); int mockUserBucket = randomUtils.randomInt(-100, 100); boolean isBackground = ran.nextBoolean(); boolean isEnabled = ran.nextBoolean(); boolean isPushEnabled = ran.nextBoolean(); Map<String, String> mockIntegrationAttributes1 = randomUtils.getRandomAttributes(4); Map<String, String> mockIntegrationAttributes2 = randomUtils.getRandomAttributes(5); Mockito.when(mockAppStateManager.getLaunchUri()).thenReturn(mockLaunchUri); Mockito.when(mockAppStateManager.getCurrentActivity()).thenReturn(new WeakReference<Activity>(mockActivity)); Mockito.when(mockAppStateManager.isBackgrounded()).thenReturn(isBackground); Mockito.when(mockConfigManager.getLatestKitConfiguration()).thenReturn(mockKitConfiguration); Mockito.when(mockConfigManager.getPushInstanceId()).thenReturn(mockPushInstanceId); Mockito.when(mockConfigManager.getPushSenderId()).thenReturn(mockPushSenderId); Mockito.when(mockConfigManager.getUserBucket()).thenReturn(mockUserBucket); Mockito.when(mockConfigManager.isEnabled()).thenReturn(isEnabled); Mockito.when(mockConfigManager.isPushEnabled()).thenReturn(isPushEnabled); Mockito.when(mockConfigManager.getIntegrationAttributes(1)).thenReturn(mockIntegrationAttributes1); Mockito.when(mockConfigManager.getIntegrationAttributes(2)).thenReturn(mockIntegrationAttributes2); CoreCallbacks coreCallbacks = new KitFrameworkWrapper.CoreCallbacksImpl(Mockito.mock(KitFrameworkWrapper.class), mockConfigManager, mockAppStateManager); assertEquals(mockActivity, coreCallbacks.getCurrentActivity().get()); assertEquals(mockKitConfiguration, coreCallbacks.getLatestKitConfiguration()); assertEquals(mockLaunchUri, coreCallbacks.getLaunchUri()); assertEquals(mockPushInstanceId, coreCallbacks.getPushInstanceId()); assertEquals(mockPushSenderId, coreCallbacks.getPushSenderId()); assertEquals(mockUserBucket, coreCallbacks.getUserBucket()); assertEquals(isBackground, coreCallbacks.isBackgrounded()); assertEquals(isEnabled, coreCallbacks.isEnabled()); assertEquals(isPushEnabled, coreCallbacks.isPushEnabled()); assertEquals(mockIntegrationAttributes1, coreCallbacks.getIntegrationAttributes(1)); assertEquals(mockIntegrationAttributes2, coreCallbacks.getIntegrationAttributes(2)); }
public WeakReference<Activity> getCurrentActivity() { return mCoreCallbacks.getCurrentActivity(); }
KitFrameworkWrapper implements KitManager { public WeakReference<Activity> getCurrentActivity() { return mCoreCallbacks.getCurrentActivity(); } }
KitFrameworkWrapper implements KitManager { public WeakReference<Activity> getCurrentActivity() { return mCoreCallbacks.getCurrentActivity(); } KitFrameworkWrapper(Context context, ReportingManager reportingManager, ConfigManager configManager, AppStateManager appStateManager, BackgroundTaskHandler backgroundTaskHandler);  KitFrameworkWrapper(Context context, ReportingManager reportingManager, ConfigManager configManager, AppStateManager appStateManager, BackgroundTaskHandler backgroundTaskHandler, boolean testing); }
KitFrameworkWrapper implements KitManager { public WeakReference<Activity> getCurrentActivity() { return mCoreCallbacks.getCurrentActivity(); } KitFrameworkWrapper(Context context, ReportingManager reportingManager, ConfigManager configManager, AppStateManager appStateManager, BackgroundTaskHandler backgroundTaskHandler);  KitFrameworkWrapper(Context context, ReportingManager reportingManager, ConfigManager configManager, AppStateManager appStateManager, BackgroundTaskHandler backgroundTaskHandler, boolean testing); void loadKitLibrary(); static boolean getKitsLoaded(); static void setKitsLoadedListener(KitsLoadedListener listener); synchronized void replayAndDisableQueue(); WeakReference<Activity> getCurrentActivity(); @Override void logEvent(BaseEvent event); @Override void logScreen(MPEvent screenEvent); @Override void leaveBreadcrumb(String breadcrumb); @Override void logError(String message, Map<String, String> eventData); @Override void logNetworkPerformance(String url, long startTime, String method, long length, long bytesSent, long bytesReceived, String requestString, int responseCode); @Override void logException(Exception exception, Map<String, String> eventData, String message); @Override void setLocation(Location location); @Override void logout(); @Override void setUserAttribute(String key, String value, long mpid); @Override void setUserAttributeList(String key, List<String> value, long mpid); @Override void removeUserAttribute(String key, long mpid); @Override void setUserTag(String tag, long mpid); @Override void incrementUserAttribute(String key, int incrementValue, String newValue, long mpid); @Override void setUserIdentity(String id, MParticle.IdentityType identityType); @Override void removeUserIdentity(MParticle.IdentityType id); @Override void setOptOut(boolean optOutStatus); @Override Uri getSurveyUrl(int kitId, Map<String, String> userAttributes, Map<String, List<String>> userAttributeLists); @Override boolean onMessageReceived(Context context, Intent intent); @Override boolean onPushRegistration(String instanceId, String senderId); @Override boolean isKitActive(int kitId); @Override Object getKitInstance(int kitId); @Override Set<Integer> getSupportedKits(); @Override void updateKits(JSONArray kitConfiguration); @Override String getActiveModuleIds(); @Override void onActivityCreated(Activity activity, Bundle savedInstanceState); @Override void onActivityStarted(Activity activity); @Override void onActivityResumed(Activity activity); @Override void onActivityPaused(Activity activity); @Override void onActivityStopped(Activity activity); @Override void onActivitySaveInstanceState(Activity activity, Bundle outState); @Override void onActivityDestroyed(Activity activity); @Override void onSessionEnd(); @Override void onSessionStart(); @Override void installReferrerUpdated(); @Override void onApplicationForeground(); @Override void onApplicationBackground(); @Override Map<Integer, AttributionResult> getAttributionResults(); @Override void onIdentifyCompleted(MParticleUser user, IdentityApiRequest request); @Override void onLoginCompleted(MParticleUser user, IdentityApiRequest request); @Override void onLogoutCompleted(MParticleUser user, IdentityApiRequest request); @Override void onModifyCompleted(MParticleUser user, IdentityApiRequest request); @Override void onConsentStateUpdated(ConsentState oldState, ConsentState newState, long mpid); @Override void reset(); }
KitFrameworkWrapper implements KitManager { public WeakReference<Activity> getCurrentActivity() { return mCoreCallbacks.getCurrentActivity(); } KitFrameworkWrapper(Context context, ReportingManager reportingManager, ConfigManager configManager, AppStateManager appStateManager, BackgroundTaskHandler backgroundTaskHandler);  KitFrameworkWrapper(Context context, ReportingManager reportingManager, ConfigManager configManager, AppStateManager appStateManager, BackgroundTaskHandler backgroundTaskHandler, boolean testing); void loadKitLibrary(); static boolean getKitsLoaded(); static void setKitsLoadedListener(KitsLoadedListener listener); synchronized void replayAndDisableQueue(); WeakReference<Activity> getCurrentActivity(); @Override void logEvent(BaseEvent event); @Override void logScreen(MPEvent screenEvent); @Override void leaveBreadcrumb(String breadcrumb); @Override void logError(String message, Map<String, String> eventData); @Override void logNetworkPerformance(String url, long startTime, String method, long length, long bytesSent, long bytesReceived, String requestString, int responseCode); @Override void logException(Exception exception, Map<String, String> eventData, String message); @Override void setLocation(Location location); @Override void logout(); @Override void setUserAttribute(String key, String value, long mpid); @Override void setUserAttributeList(String key, List<String> value, long mpid); @Override void removeUserAttribute(String key, long mpid); @Override void setUserTag(String tag, long mpid); @Override void incrementUserAttribute(String key, int incrementValue, String newValue, long mpid); @Override void setUserIdentity(String id, MParticle.IdentityType identityType); @Override void removeUserIdentity(MParticle.IdentityType id); @Override void setOptOut(boolean optOutStatus); @Override Uri getSurveyUrl(int kitId, Map<String, String> userAttributes, Map<String, List<String>> userAttributeLists); @Override boolean onMessageReceived(Context context, Intent intent); @Override boolean onPushRegistration(String instanceId, String senderId); @Override boolean isKitActive(int kitId); @Override Object getKitInstance(int kitId); @Override Set<Integer> getSupportedKits(); @Override void updateKits(JSONArray kitConfiguration); @Override String getActiveModuleIds(); @Override void onActivityCreated(Activity activity, Bundle savedInstanceState); @Override void onActivityStarted(Activity activity); @Override void onActivityResumed(Activity activity); @Override void onActivityPaused(Activity activity); @Override void onActivityStopped(Activity activity); @Override void onActivitySaveInstanceState(Activity activity, Bundle outState); @Override void onActivityDestroyed(Activity activity); @Override void onSessionEnd(); @Override void onSessionStart(); @Override void installReferrerUpdated(); @Override void onApplicationForeground(); @Override void onApplicationBackground(); @Override Map<Integer, AttributionResult> getAttributionResults(); @Override void onIdentifyCompleted(MParticleUser user, IdentityApiRequest request); @Override void onLoginCompleted(MParticleUser user, IdentityApiRequest request); @Override void onLogoutCompleted(MParticleUser user, IdentityApiRequest request); @Override void onModifyCompleted(MParticleUser user, IdentityApiRequest request); @Override void onConsentStateUpdated(ConsentState oldState, ConsentState newState, long mpid); @Override void reset();  }