@Test public void activityStop() { integration.onActivityStopped(activity); verify(moeHelper).onStop(activity); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }
@Test public void reset() { integration.reset(); verify(moeHelper).logoutUser(); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }
@Test public void activityResume() { integration.onActivityResumed(activity); verify(moeHelper).onResume(activity); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }
@Test public void activityCreate() { Bundle bundle = mock(Bundle.class); integration.onActivityCreated(activity, bundle); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }
@Test public void activitySaveInstance() { Bundle bundle = mock(Bundle.class); integration.onActivitySaveInstanceState(activity, bundle); verify(moeHelper).onSaveInstanceState(bundle); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }
@Test public void track() throws JSONException { TrackPayloadBuilder builder = new TrackPayloadBuilder(); builder.event("foo").properties(new Properties().putCurrency("INR").putPrice(2000.0)); integration.track(builder.build()); JSONObject eventProperties = new JSONObject(); eventProperties.put("currency", "INR"); eventProperties.put("price", 2000.0); verify(moeHelper).trackEvent(eq("foo"), jsonEq(eventProperties)); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }
@Before public void setUp() throws PackageManager.NameNotFoundException { initMocks(this); mockStatic(MoEHelper.class); when(analytics.getApplication()).thenReturn(context); when(context.getPackageManager()).thenReturn(manager); when(activity.getPackageManager()).thenReturn(manager); when(manager.getApplicationInfo(context.getPackageName(), 0)).thenReturn(applicationInfo); when(context.getApplicationContext()).thenReturn(RuntimeEnvironment.application); integration = new MoEngageIntegration( analytics, new ValueMap().putValue("pushSenderId", "12324441").putValue("apiKey", "ASJKSLJAL")); integration.helper = moeHelper; }
@Test public void identify() throws ParseException { Traits traits = createTraits("foo") // .putValue("anonymousId", "bar") .putEmail("*****@*****.**") .putPhone("123-542-7189") .putName("Mr. Prateek") .putFirstName("Prateek") .putLastName("Srivastava") .putGender("male"); AnalyticsContext analyticsContext = createContext(traits) // .putLocation(new AnalyticsContext.Location().putLatitude(10).putLongitude(20)); integration.identify( new IdentifyPayloadBuilder() // .traits(traits) .context(analyticsContext) .build()); HashMap<String, Object> userAttributes = new LinkedHashMap<>(); userAttributes.put("USER_ATTRIBUTE_SEGMENT_ID", "bar"); userAttributes.put(MoEHelperConstants.USER_ATTRIBUTE_UNIQUE_ID, "foo"); userAttributes.put(MoEHelperConstants.USER_ATTRIBUTE_USER_EMAIL, "*****@*****.**"); userAttributes.put(MoEHelperConstants.USER_ATTRIBUTE_USER_MOBILE, "123-542-7189"); userAttributes.put(MoEHelperConstants.USER_ATTRIBUTE_USER_NAME, "Mr. Prateek"); userAttributes.put(MoEHelperConstants.USER_ATTRIBUTE_USER_FIRST_NAME, "Prateek"); userAttributes.put(MoEHelperConstants.USER_ATTRIBUTE_USER_LAST_NAME, "Srivastava"); userAttributes.put(MoEHelperConstants.USER_ATTRIBUTE_USER_GENDER, "male"); verify(moeHelper).setUserAttribute(mapEq(userAttributes)); verify(moeHelper) .setUserAttribute(MoEHelperConstants.USER_ATTRIBUTE_USER_LOCATION, new GeoLocation(10, 20)); verifyNoMoreInteractions(moeHelper); verifyNoMoreInteractions(MoEHelper.class); }
@Test public void flush() { integration.flush(); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }
@Test public void screen() { integration.screen(new ScreenPayloadBuilder().build()); verifyNoMoreInteractions(MoEHelper.class); verifyNoMoreInteractions(moeHelper); }