Tracker { Tracker setParam(String key, Closure value) { return processSetParam(key, value); } Tracker();   Tracker(boolean registerNeeded);  Tracker(android.content.Context context);   Tracker(android.content.Context context, boolean registerNeeded);  Tracker(final HashMap<String, Object> configuration);   Tracker(final HashMap<String, Object> configuration, boolean registerNeeded);  Tracker(android.content.Context context, final HashMap<String, Object> configuration);   Tracker(android.content.Context context, final HashMap<String, Object> configuration, boolean registerNeeded); LinkedHashMap<String, BusinessObject> getBusinessObjects(); Configuration getConfiguration(); TrackerListener getListener(); void getUserId(final UserIdCallback callback); String getUserIdSync(); void setUserId(String value); Screens Screens(); Gestures Gestures(); Events Events(); ECommerce ECommerce(); AVInsights AVInsights(); Offline Offline(); Context Context(); NuggAds NuggAds(); CustomObjects CustomObjects(); IdentifiedVisitor IdentifiedVisitor(); Publishers Publishers(); SelfPromotions SelfPromotions(); DynamicScreens DynamicScreens(); Products Products(); Cart Cart(); MediaPlayers Players(); @Deprecated Locations Locations(); @Deprecated CustomVars CustomVars(); @Deprecated Aisles Aisles(); Campaigns Campaigns(); @Deprecated CustomTreeStructures CustomTreeStructures(); @Deprecated InternalSearches InternalSearches(); Orders Orders(); MvTestings MvTestings(); void setLog(String log, SetConfigCallback setConfigCallback, boolean... sync); void setSecuredLog(String securedLog, SetConfigCallback setConfigCallback, boolean... sync); void setDomain(String domain, SetConfigCallback setConfigCallback, boolean... sync); void setSiteId(int siteId, SetConfigCallback setConfigCallback, boolean... sync); void setOfflineMode(OfflineMode offlineMode, SetConfigCallback setConfigCallback, boolean... sync); @Deprecated void setSecureModeEnabled(boolean enabled, SetConfigCallback setConfigCallback, boolean... sync); void setIdentifierType(IdentifierType identifierType, SetConfigCallback setConfigCallback, boolean... sync); void setIgnoreLimitedAdTrackingEnabled(boolean enabled, SetConfigCallback setConfigCallback, boolean... sync); void setSendHitWhenOptOutEnabled(boolean enabled, SetConfigCallback setConfigCallback, boolean... sync); void setHashUserIdEnabled(boolean enabled, SetConfigCallback setConfigCallback, boolean... sync); void setPlugins(List<PluginKey> plugins, SetConfigCallback setConfigCallback, boolean... sync); void setPixelPath(String pixelPath, SetConfigCallback setConfigCallback, boolean... sync); void setPersistentIdentifiedVisitorEnabled(boolean enabled, SetConfigCallback setConfigCallback, boolean... sync); void setCrashDetectionEnabled(boolean enabled, SetConfigCallback setConfigCallback, boolean... sync); void setCampaignLastPersistenceEnabled(boolean enabled, SetConfigCallback setConfigCallback, boolean... sync); void setCampaignLifetime(int lifetime, SetConfigCallback setConfigCallback, boolean... sync); void setSessionBackgroundDuration(int duration, SetConfigCallback setConfigCallback, boolean... sync); void setMaxHitSize(int maxHitSize); void setUUIDDuration(int uuidDuration); void setUUIDExpirationMode(UUIDExpirationMode uuidExpirationMode); TrackerListener createDefaultTrackerListener(); @Deprecated void setConfig(final HashMap<String, Object> conf, final boolean override, final SetConfigCallback setConfigCallback, boolean... sync); void setConfig(final HashMap<String, Object> conf, final SetConfigCallback setConfigCallback, boolean... sync); void setConfig(final String key, final Object value, final SetConfigCallback setConfigCallback, boolean... sync); Tracker setListener(TrackerListener trackerListener); Tracker setDefaultListener(); @Deprecated static void optOut(final boolean enabled); @Deprecated static boolean optOutEnabled(); @Deprecated static void doNotTrack(final boolean enabled); @Deprecated static boolean doNotTrackEnabled(); Tracker setParam(String key, int value); Tracker setParam(String key, int value, ParamOption options); Tracker setParam(String key, float value); Tracker setParam(String key, float value, ParamOption options); Tracker setParam(String key, double value); Tracker setParam(String key, double value, ParamOption options); Tracker setParam(String key, boolean value); Tracker setParam(String key, boolean value, ParamOption options); Tracker setParam(String key, String value); Tracker setProp(String key, final String value, boolean persistent); Tracker setProps(Map<String, String> props, boolean persistent); Param getProp(String key); List<Param> getProps(); void delProp(String key); void delProps(); Tracker setParam(String key, final String value, ParamOption options); Tracker setParam(String key, List value); Tracker setParam(String key, List value, ParamOption options); Tracker setParam(String key, Object[] value); Tracker setParam(String key, Object[] value, ParamOption options); Tracker setParam(String key, Map value); Tracker setParam(String key, Map value, ParamOption options); void unsetParam(String key); void resetScreenContext(); void dispatch(); Map<String, Object> getLifecycleMetrics(); Map<String, String> getCrashInformation(); String getSdkVersion();  }
@Test public void emptyParameterTest() { tracker.setParam("test", ""); Builder builder = new Builder(tracker); String url = builder.build().first.get(0); assertTrue(url.contains("&test=")); }
@Test public void setParamIntTest() { tracker.setParam(key, 1); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("1", buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamBooleanTest() { tracker.setParam(key, true); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("true", buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamFloatTest() { tracker.setParam(key, 1.f); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals(String.valueOf(1.f), buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamDoubleTest() { tracker.setParam(key, 1.5); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("1.5", buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamStringTest() { tracker.setParam(key, "StringValue"); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("StringValue", buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamArrayTest() { ArrayList<Integer> array = new ArrayList<Integer>() {{ add(1); add(2); add(3); }}; tracker.setParam(key, array); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("1,2,3", buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamTabTest() { Float[] tab = new Float[]{1.f, 2.f}; tracker.setParam(key, tab); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("1.0,2.0", buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamMapTest() { HashMap<String, Boolean> map = new HashMap<String, Boolean>() {{ put("boolean1", true); put("boolean2", false); }}; tracker.setParam(key, map); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("{\"boolean2\":false,\"boolean1\":true}", buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamClosureTest() { Closure closure = new Closure() { @Override public String execute() { return String.valueOf(DateFormat.format(pattern, System.currentTimeMillis())); } }; tracker.setParam(key, closure); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get(key).getValues().size()); assertEquals(today, buffer.getVolatileParams().get(key).getValues().get(0).execute()); }
@Test public void setParamWithOptions() { ParamOption options = new ParamOption().setPersistent(true).setAppend(true); tracker.setParam(key, 1, options); assertEquals(0, buffer.getVolatileParams().size()); assertEquals(1, buffer.getPersistentParams().size()); assertEquals(1, buffer.getPersistentParams().get(key).getValues().size()); assertEquals(true, buffer.getPersistentParams().get(key).getOptions().isAppend()); assertEquals("1", buffer.getPersistentParams().get(key).getValues().get(0).execute()); }
@Test public void setParamComplex() { ParamOption options = new ParamOption().setPersistent(true).setAppend(true); tracker.setParam(key, 1) .setParam(key, "test"); tracker.setParam(key, 1, options) .setParam(key, 67, options); assertEquals(1, buffer.getVolatileParams().size()); assertEquals(1, buffer.getPersistentParams().size()); assertEquals(3, buffer.getVolatileParams().get(key).getValues().size()); assertEquals("test", buffer.getVolatileParams().get(key).getValues().get(0).execute()); assertEquals("1", buffer.getVolatileParams().get(key).getValues().get(1).execute()); assertEquals("67", buffer.getVolatileParams().get(key).getValues().get(2).execute()); assertEquals(2, buffer.getPersistentParams().get(key).getValues().size()); assertEquals(true, buffer.getPersistentParams().get(key).getOptions().isAppend()); assertEquals("1", buffer.getPersistentParams().get(key).getValues().get(0).execute()); assertEquals("67", buffer.getPersistentParams().get(key).getValues().get(1).execute()); }