@Test public void replaceMacros_urlWithoutMacros_returnInputUrl() { String url = "http: assertEquals( url, SessionTracker.replaceMacros( url, new TrackEventInfo(), 100, 500)); }
@Nullable @VisibleForTesting static String replaceMacros(@Nullable String url, @Nullable TrackEventInfo info, int processCode, int errorCode) { if (TextUtils.isEmpty(url)) return null; assert url != null; String outUrl = url; outUrl = replaceMacros(outUrl, "BM_EVENT_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ACTION_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ERROR_REASON", errorCode); if (info != null) { outUrl = replaceMacros(outUrl, "BM_ACTION_START", info.startTimeMs); outUrl = replaceMacros(outUrl, "BM_ACTION_FINISH", info.finishTimeMs); Map<String, Object> eventParameters = info.getEventParameters(); if (eventParameters != null) { for (Map.Entry<String, Object> parameter : eventParameters.entrySet()) { outUrl = replaceMacros(outUrl, parameter.getKey(), parameter.getValue()); } } } return outUrl; }
SessionTracker { @Nullable @VisibleForTesting static String replaceMacros(@Nullable String url, @Nullable TrackEventInfo info, int processCode, int errorCode) { if (TextUtils.isEmpty(url)) return null; assert url != null; String outUrl = url; outUrl = replaceMacros(outUrl, "BM_EVENT_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ACTION_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ERROR_REASON", errorCode); if (info != null) { outUrl = replaceMacros(outUrl, "BM_ACTION_START", info.startTimeMs); outUrl = replaceMacros(outUrl, "BM_ACTION_FINISH", info.finishTimeMs); Map<String, Object> eventParameters = info.getEventParameters(); if (eventParameters != null) { for (Map.Entry<String, Object> parameter : eventParameters.entrySet()) { outUrl = replaceMacros(outUrl, parameter.getKey(), parameter.getValue()); } } } return outUrl; } }
SessionTracker { @Nullable @VisibleForTesting static String replaceMacros(@Nullable String url, @Nullable TrackEventInfo info, int processCode, int errorCode) { if (TextUtils.isEmpty(url)) return null; assert url != null; String outUrl = url; outUrl = replaceMacros(outUrl, "BM_EVENT_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ACTION_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ERROR_REASON", errorCode); if (info != null) { outUrl = replaceMacros(outUrl, "BM_ACTION_START", info.startTimeMs); outUrl = replaceMacros(outUrl, "BM_ACTION_FINISH", info.finishTimeMs); Map<String, Object> eventParameters = info.getEventParameters(); if (eventParameters != null) { for (Map.Entry<String, Object> parameter : eventParameters.entrySet()) { outUrl = replaceMacros(outUrl, parameter.getKey(), parameter.getValue()); } } } return outUrl; }  }
SessionTracker { @Nullable @VisibleForTesting static String replaceMacros(@Nullable String url, @Nullable TrackEventInfo info, int processCode, int errorCode) { if (TextUtils.isEmpty(url)) return null; assert url != null; String outUrl = url; outUrl = replaceMacros(outUrl, "BM_EVENT_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ACTION_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ERROR_REASON", errorCode); if (info != null) { outUrl = replaceMacros(outUrl, "BM_ACTION_START", info.startTimeMs); outUrl = replaceMacros(outUrl, "BM_ACTION_FINISH", info.finishTimeMs); Map<String, Object> eventParameters = info.getEventParameters(); if (eventParameters != null) { for (Map.Entry<String, Object> parameter : eventParameters.entrySet()) { outUrl = replaceMacros(outUrl, parameter.getKey(), parameter.getValue()); } } } return outUrl; }   }
SessionTracker { @Nullable @VisibleForTesting static String replaceMacros(@Nullable String url, @Nullable TrackEventInfo info, int processCode, int errorCode) { if (TextUtils.isEmpty(url)) return null; assert url != null; String outUrl = url; outUrl = replaceMacros(outUrl, "BM_EVENT_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ACTION_CODE", processCode); outUrl = replaceMacros(outUrl, "BM_ERROR_REASON", errorCode); if (info != null) { outUrl = replaceMacros(outUrl, "BM_ACTION_START", info.startTimeMs); outUrl = replaceMacros(outUrl, "BM_ACTION_FINISH", info.finishTimeMs); Map<String, Object> eventParameters = info.getEventParameters(); if (eventParameters != null) { for (Map.Entry<String, Object> parameter : eventParameters.entrySet()) { outUrl = replaceMacros(outUrl, parameter.getKey(), parameter.getValue()); } } } return outUrl; }    }