@Test @SuppressWarnings("unchecked") public void testLoadError() { final ParameterizedCommand<StunnerPreferences> loadCompleteCallback = mock(ParameterizedCommand.class); final ParameterizedCommand<Throwable> errorCallback = mock(ParameterizedCommand.class); final Throwable errorInstance = mock(Throwable.class); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { ((ParameterizedCommand<Throwable>) invocation.getArguments()[1]).execute(errorInstance); return null; } }).when(preferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class)); tested.load(metadata, loadCompleteCallback, errorCallback); verify(preferencesHolders, times(1)).select(eq(qualifier)); verify(errorCallback, times(1)).execute(eq(errorInstance)); verify(loadCompleteCallback, never()).execute(any(StunnerPreferences.class)); verify(preferencesHolder, never()).set(any(StunnerPreferences.class), eq(StunnerPreferences.class)); verify(preferencesHolder, never()).set(any(StunnerTextPreferences.class), eq(StunnerTextPreferences.class)); }
public void load(final Metadata metadata, final ParameterizedCommand<StunnerPreferences> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { final String definitionSetId = metadata.getDefinitionSetId(); final Annotation qualifier = definitionUtils.getQualifier(definitionSetId); final StunnerPreferencesRegistryHolder holder = InstanceUtils.lookup(preferencesHolders, qualifier); preferences.load(prefs -> { holder.set(prefs, StunnerPreferences.class); holder.set(textPreferences, StunnerTextPreferences.class); loadCompleteCallback.execute(prefs); }, errorCallback); }
StunnerPreferencesRegistryLoader { public void load(final Metadata metadata, final ParameterizedCommand<StunnerPreferences> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { final String definitionSetId = metadata.getDefinitionSetId(); final Annotation qualifier = definitionUtils.getQualifier(definitionSetId); final StunnerPreferencesRegistryHolder holder = InstanceUtils.lookup(preferencesHolders, qualifier); preferences.load(prefs -> { holder.set(prefs, StunnerPreferences.class); holder.set(textPreferences, StunnerTextPreferences.class); loadCompleteCallback.execute(prefs); }, errorCallback); } }
StunnerPreferencesRegistryLoader { public void load(final Metadata metadata, final ParameterizedCommand<StunnerPreferences> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { final String definitionSetId = metadata.getDefinitionSetId(); final Annotation qualifier = definitionUtils.getQualifier(definitionSetId); final StunnerPreferencesRegistryHolder holder = InstanceUtils.lookup(preferencesHolders, qualifier); preferences.load(prefs -> { holder.set(prefs, StunnerPreferences.class); holder.set(textPreferences, StunnerTextPreferences.class); loadCompleteCallback.execute(prefs); }, errorCallback); } @Inject  StunnerPreferencesRegistryLoader(final DefinitionUtils definitionUtils,
                                            final @Any ManagedInstance<StunnerPreferencesRegistryHolder> preferencesHolders,
                                            final StunnerPreferences preferences,
                                            final StunnerTextPreferences textPreferences); }
StunnerPreferencesRegistryLoader { public void load(final Metadata metadata, final ParameterizedCommand<StunnerPreferences> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { final String definitionSetId = metadata.getDefinitionSetId(); final Annotation qualifier = definitionUtils.getQualifier(definitionSetId); final StunnerPreferencesRegistryHolder holder = InstanceUtils.lookup(preferencesHolders, qualifier); preferences.load(prefs -> { holder.set(prefs, StunnerPreferences.class); holder.set(textPreferences, StunnerTextPreferences.class); loadCompleteCallback.execute(prefs); }, errorCallback); } @Inject  StunnerPreferencesRegistryLoader(final DefinitionUtils definitionUtils,
                                            final @Any ManagedInstance<StunnerPreferencesRegistryHolder> preferencesHolders,
                                            final StunnerPreferences preferences,
                                            final StunnerTextPreferences textPreferences); void load(final Metadata metadata,
                     final ParameterizedCommand<StunnerPreferences> loadCompleteCallback,
                     final ParameterizedCommand<Throwable> errorCallback); @PreDestroy void destroy(); }
StunnerPreferencesRegistryLoader { public void load(final Metadata metadata, final ParameterizedCommand<StunnerPreferences> loadCompleteCallback, final ParameterizedCommand<Throwable> errorCallback) { final String definitionSetId = metadata.getDefinitionSetId(); final Annotation qualifier = definitionUtils.getQualifier(definitionSetId); final StunnerPreferencesRegistryHolder holder = InstanceUtils.lookup(preferencesHolders, qualifier); preferences.load(prefs -> { holder.set(prefs, StunnerPreferences.class); holder.set(textPreferences, StunnerTextPreferences.class); loadCompleteCallback.execute(prefs); }, errorCallback); } @Inject  StunnerPreferencesRegistryLoader(final DefinitionUtils definitionUtils,
                                            final @Any ManagedInstance<StunnerPreferencesRegistryHolder> preferencesHolders,
                                            final StunnerPreferences preferences,
                                            final StunnerTextPreferences textPreferences); void load(final Metadata metadata,
                     final ParameterizedCommand<StunnerPreferences> loadCompleteCallback,
                     final ParameterizedCommand<Throwable> errorCallback); @PreDestroy void destroy();  }