@Test public void providersAreSortedByPriorityFirst() throws Exception { when(this.provider1.getPriority()).thenReturn(100); when(this.provider2.getPriority()).thenReturn(200); when(this.provider3.getPriority()).thenReturn(300); this.mocker.registerComponent(PatientContactProvider.class, "y", this.provider2); this.mocker.registerComponent(PatientContactProvider.class, "z", this.provider1); this.mocker.registerComponent(PatientContactProvider.class, "x", this.provider3); List<PatientContactProvider> result = this.mocker.getComponentUnderTest().get(); Assert.assertEquals(3, result.size()); Assert.assertSame(this.provider1, result.get(0)); Assert.assertSame(this.provider2, result.get(1)); Assert.assertSame(this.provider3, result.get(2)); }
@Override public List<PatientContactProvider> get() { try { List<PatientContactProvider> services = new LinkedList<>(); services .addAll(this.componentManager.<PatientContactProvider>getInstanceList(PatientContactProvider.class)); Collections.sort(services, PatientContactProviderComparator.INSTANCE); return services; } catch (ComponentLookupException ex) { return Collections.emptyList(); } }
PatientContactProviderListProvider implements Provider<List<PatientContactProvider>> { @Override public List<PatientContactProvider> get() { try { List<PatientContactProvider> services = new LinkedList<>(); services .addAll(this.componentManager.<PatientContactProvider>getInstanceList(PatientContactProvider.class)); Collections.sort(services, PatientContactProviderComparator.INSTANCE); return services; } catch (ComponentLookupException ex) { return Collections.emptyList(); } } }
PatientContactProviderListProvider implements Provider<List<PatientContactProvider>> { @Override public List<PatientContactProvider> get() { try { List<PatientContactProvider> services = new LinkedList<>(); services .addAll(this.componentManager.<PatientContactProvider>getInstanceList(PatientContactProvider.class)); Collections.sort(services, PatientContactProviderComparator.INSTANCE); return services; } catch (ComponentLookupException ex) { return Collections.emptyList(); } }  }
PatientContactProviderListProvider implements Provider<List<PatientContactProvider>> { @Override public List<PatientContactProvider> get() { try { List<PatientContactProvider> services = new LinkedList<>(); services .addAll(this.componentManager.<PatientContactProvider>getInstanceList(PatientContactProvider.class)); Collections.sort(services, PatientContactProviderComparator.INSTANCE); return services; } catch (ComponentLookupException ex) { return Collections.emptyList(); } }  @Override List<PatientContactProvider> get(); }
PatientContactProviderListProvider implements Provider<List<PatientContactProvider>> { @Override public List<PatientContactProvider> get() { try { List<PatientContactProvider> services = new LinkedList<>(); services .addAll(this.componentManager.<PatientContactProvider>getInstanceList(PatientContactProvider.class)); Collections.sort(services, PatientContactProviderComparator.INSTANCE); return services; } catch (ComponentLookupException ex) { return Collections.emptyList(); } }  @Override List<PatientContactProvider> get();  }