@Test public void testEmptyAttributeUpdates() { namedUser.editAttributes().apply(); verifyZeroInteractions(mockDispatcher); }
@NonNull public AttributeEditor editAttributes() { return new AttributeEditor(clock) { @Override protected void onApply(@NonNull List<AttributeMutation> mutations) { if (!isDataCollectionEnabled()) { Logger.info("Ignore attributes, data opted out."); return; } if (!mutations.isEmpty()) { attributeRegistrar.addPendingMutations(mutations); dispatchNamedUserUpdateJob(); } } }; }
NamedUser extends AirshipComponent { @NonNull public AttributeEditor editAttributes() { return new AttributeEditor(clock) { @Override protected void onApply(@NonNull List<AttributeMutation> mutations) { if (!isDataCollectionEnabled()) { Logger.info("Ignore attributes, data opted out."); return; } if (!mutations.isEmpty()) { attributeRegistrar.addPendingMutations(mutations); dispatchNamedUserUpdateJob(); } } }; } }
NamedUser extends AirshipComponent { @NonNull public AttributeEditor editAttributes() { return new AttributeEditor(clock) { @Override protected void onApply(@NonNull List<AttributeMutation> mutations) { if (!isDataCollectionEnabled()) { Logger.info("Ignore attributes, data opted out."); return; } if (!mutations.isEmpty()) { attributeRegistrar.addPendingMutations(mutations); dispatchNamedUserUpdateJob(); } } }; } NamedUser(@NonNull Context context, @NonNull PreferenceDataStore preferenceDataStore,
                     @NonNull AirshipRuntimeConfig runtimeConfig, @NonNull AirshipChannel airshipChannel); @VisibleForTesting  NamedUser(@NonNull Context context, @NonNull PreferenceDataStore preferenceDataStore,
              @NonNull AirshipChannel airshipChannel, @NonNull JobDispatcher dispatcher,
              @NonNull Clock clock, @NonNull NamedUserApiClient namedUserApiClient,
              @NonNull AttributeRegistrar attributeRegistrar, @NonNull TagGroupRegistrar tagGroupRegistrar); }
NamedUser extends AirshipComponent { @NonNull public AttributeEditor editAttributes() { return new AttributeEditor(clock) { @Override protected void onApply(@NonNull List<AttributeMutation> mutations) { if (!isDataCollectionEnabled()) { Logger.info("Ignore attributes, data opted out."); return; } if (!mutations.isEmpty()) { attributeRegistrar.addPendingMutations(mutations); dispatchNamedUserUpdateJob(); } } }; } NamedUser(@NonNull Context context, @NonNull PreferenceDataStore preferenceDataStore,
                     @NonNull AirshipRuntimeConfig runtimeConfig, @NonNull AirshipChannel airshipChannel); @VisibleForTesting  NamedUser(@NonNull Context context, @NonNull PreferenceDataStore preferenceDataStore,
              @NonNull AirshipChannel airshipChannel, @NonNull JobDispatcher dispatcher,
              @NonNull Clock clock, @NonNull NamedUserApiClient namedUserApiClient,
              @NonNull AttributeRegistrar attributeRegistrar, @NonNull TagGroupRegistrar tagGroupRegistrar); @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @AirshipComponentGroups.Group int getComponentGroup(); @Override @WorkerThread @JobInfo.JobResult @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) int onPerformJob(@NonNull UAirship airship, @NonNull JobInfo jobInfo); @NonNull @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) List<TagGroupsMutation> getPendingTagUpdates(); @NonNull @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) List<AttributeMutation> getPendingAttributeUpdates(); @Nullable String getId(); void forceUpdate(); void setId(@Nullable @Size(max = MAX_NAMED_USER_ID_LENGTH) String namedUserId); @NonNull TagGroupsEditor editTagGroups(); @NonNull AttributeEditor editAttributes(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void addTagGroupListener(@NonNull TagGroupListener listener); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void addAttributeListener(@NonNull AttributeListener listener); }
NamedUser extends AirshipComponent { @NonNull public AttributeEditor editAttributes() { return new AttributeEditor(clock) { @Override protected void onApply(@NonNull List<AttributeMutation> mutations) { if (!isDataCollectionEnabled()) { Logger.info("Ignore attributes, data opted out."); return; } if (!mutations.isEmpty()) { attributeRegistrar.addPendingMutations(mutations); dispatchNamedUserUpdateJob(); } } }; } NamedUser(@NonNull Context context, @NonNull PreferenceDataStore preferenceDataStore,
                     @NonNull AirshipRuntimeConfig runtimeConfig, @NonNull AirshipChannel airshipChannel); @VisibleForTesting  NamedUser(@NonNull Context context, @NonNull PreferenceDataStore preferenceDataStore,
              @NonNull AirshipChannel airshipChannel, @NonNull JobDispatcher dispatcher,
              @NonNull Clock clock, @NonNull NamedUserApiClient namedUserApiClient,
              @NonNull AttributeRegistrar attributeRegistrar, @NonNull TagGroupRegistrar tagGroupRegistrar); @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @AirshipComponentGroups.Group int getComponentGroup(); @Override @WorkerThread @JobInfo.JobResult @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) int onPerformJob(@NonNull UAirship airship, @NonNull JobInfo jobInfo); @NonNull @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) List<TagGroupsMutation> getPendingTagUpdates(); @NonNull @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) List<AttributeMutation> getPendingAttributeUpdates(); @Nullable String getId(); void forceUpdate(); void setId(@Nullable @Size(max = MAX_NAMED_USER_ID_LENGTH) String namedUserId); @NonNull TagGroupsEditor editTagGroups(); @NonNull AttributeEditor editAttributes(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void addTagGroupListener(@NonNull TagGroupListener listener); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void addAttributeListener(@NonNull AttributeListener listener);  }