PropertyConfigurator extends AbstractChannelListener { public synchronized void setEventProperty(String key, boolean value) { mEventProperties.set(key, value); } PropertyConfigurator(AnalyticsTransmissionTarget transmissionTarget); @Override void onPreparingLog(@NonNull Log log, @NonNull String groupName); void setAppName(final String appName); void setAppVersion(final String appVersion); void setAppLocale(final String appLocale); void setUserId(final String userId); synchronized void setEventProperty(String key, boolean value); synchronized void setEventProperty(String key, Date value); synchronized void setEventProperty(String key, double value); synchronized void setEventProperty(String key, long value); synchronized void setEventProperty(String key, String value); synchronized void removeEventProperty(String key); void collectDeviceId();  }
@Test public void setCommonEventProperties() { AnalyticsTransmissionTarget target = Analytics.getTransmissionTarget("test"); target.getPropertyConfigurator().setEventProperty("key", "value"); target.trackEvent("eventName"); ArgumentCaptor<EventLog> eventLogArg = ArgumentCaptor.forClass(EventLog.class); verify(mChannel).enqueue(eventLogArg.capture(), anyString(), eq(DEFAULTS)); EventLog log = eventLogArg.getValue(); assertNotNull(log); assertEquals(Collections.singleton("test"), log.getTransmissionTargetTokens()); assertEquals("eventName", log.getName()); assertNull(log.getProperties()); List<TypedProperty> typedProperties = new ArrayList<>(); typedProperties.add(typedProperty("key", "value")); assertEquals(typedProperties, log.getTypedProperties()); }
@Test public void setCommonEventPropertiesWithNullMapProperties() { AnalyticsTransmissionTarget target = Analytics.getTransmissionTarget("test"); target.getPropertyConfigurator().setEventProperty("key", "value"); target.trackEvent("eventName", (Map<String, String>) null); ArgumentCaptor<EventLog> eventLogArg = ArgumentCaptor.forClass(EventLog.class); verify(mChannel).enqueue(eventLogArg.capture(), anyString(), eq(DEFAULTS)); EventLog log = eventLogArg.getValue(); assertNotNull(log); assertEquals(Collections.singleton("test"), log.getTransmissionTargetTokens()); assertEquals("eventName", log.getName()); assertNull(log.getProperties()); List<TypedProperty> typedProperties = new ArrayList<>(); typedProperties.add(typedProperty("key", "value")); assertEquals(typedProperties, log.getTypedProperties()); }