diff --git a/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardController.java b/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardController.java index bbcebbe6a2e..3b0b46d2f2b 100644 --- a/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardController.java +++ b/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardController.java @@ -128,8 +128,10 @@ public class LegacySuggestionContextualCardController implements ContextualCardC return; } final List suggestions = mSuggestionController.getSuggestions(); - Log.d(TAG, "Loaded suggests: " - + suggestions == null ? "null" : String.valueOf(suggestions.size())); + final String suggestionCount = suggestions == null + ? "null" + : String.valueOf(suggestions.size()); + Log.d(TAG, "Loaded suggests: " + suggestionCount); final List cards = new ArrayList<>(); if (suggestions != null) { diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardControllerTest.java index ebc2154a009..a2d4d093c42 100644 --- a/tests/robotests/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardControllerTest.java +++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/legacysuggestion/LegacySuggestionContextualCardControllerTest.java @@ -19,6 +19,7 @@ package com.android.settings.homepage.contextualcards.legacysuggestion; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import android.content.Context; @@ -84,8 +85,10 @@ public class LegacySuggestionContextualCardControllerTest { @Test public void onServiceConnected_shouldLoadSuggestion() { + when(mSuggestionController.getSuggestions()).thenReturn(null); mController.mSuggestionController = mSuggestionController; mController.setCardUpdateListener(mCardUpdateListener); + mController.onServiceConnected(); verify(mSuggestionController).getSuggestions();