@Test @SuppressWarnings("unchecked") public void testError() { final Throwable exception = mock(Throwable.class); doAnswer(invocation -> { ParameterizedCommand<Throwable> callback = (ParameterizedCommand<Throwable>) invocation.getArguments()[1]; callback.execute(exception); return null; }).when(profilePreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class)); ParameterizedCommand<Profile> loadCallback = mock(ParameterizedCommand.class); ParameterizedCommand<Throwable> errorCallback = mock(ParameterizedCommand.class); tested.load(metadata, loadCallback, errorCallback); verify(errorCallback, times(1)).execute(eq(exception)); verify(loadCallback, never()).execute(any(Profile.class)); }
public void load(final Metadata metadata, final ParameterizedCommand<Profile> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { profilePreferences .load(profilePreferences -> { final String profileName = profilePreferences.getProfile().getName(); loadCompleteCallback.execute(getProfileByPreference(metadata, profileName) .orElse(defaultProfile)); }, errorCallback); }
StunnerProfilePreferencesLoader { public void load(final Metadata metadata, final ParameterizedCommand<Profile> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { profilePreferences .load(profilePreferences -> { final String profileName = profilePreferences.getProfile().getName(); loadCompleteCallback.execute(getProfileByPreference(metadata, profileName) .orElse(defaultProfile)); }, errorCallback); } }
StunnerProfilePreferencesLoader { public void load(final Metadata metadata, final ParameterizedCommand<Profile> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { profilePreferences .load(profilePreferences -> { final String profileName = profilePreferences.getProfile().getName(); loadCompleteCallback.execute(getProfileByPreference(metadata, profileName) .orElse(defaultProfile)); }, errorCallback); } @Inject  StunnerProfilePreferencesLoader(final ProfileManager profileManager,
                                           final ProfilePreferences profilePreferences,
                                           final FullProfile defaultProfile); }
StunnerProfilePreferencesLoader { public void load(final Metadata metadata, final ParameterizedCommand<Profile> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { profilePreferences .load(profilePreferences -> { final String profileName = profilePreferences.getProfile().getName(); loadCompleteCallback.execute(getProfileByPreference(metadata, profileName) .orElse(defaultProfile)); }, errorCallback); } @Inject  StunnerProfilePreferencesLoader(final ProfileManager profileManager,
                                           final ProfilePreferences profilePreferences,
                                           final FullProfile defaultProfile); void load(final Metadata metadata,
                     final ParameterizedCommand<Profile> loadCompleteCallback,
                     final ParameterizedCommand<Throwable> errorCallback); }
StunnerProfilePreferencesLoader { public void load(final Metadata metadata, final ParameterizedCommand<Profile> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { profilePreferences .load(profilePreferences -> { final String profileName = profilePreferences.getProfile().getName(); loadCompleteCallback.execute(getProfileByPreference(metadata, profileName) .orElse(defaultProfile)); }, errorCallback); } @Inject  StunnerProfilePreferencesLoader(final ProfileManager profileManager,
                                           final ProfilePreferences profilePreferences,
                                           final FullProfile defaultProfile); void load(final Metadata metadata,
                     final ParameterizedCommand<Profile> loadCompleteCallback,
                     final ParameterizedCommand<Throwable> errorCallback);  }