@Test public void testGetProviders() { List<Provider> result = runtimeRegistry.getProviders(0, 1000, RuntimeRegistry.PROVIDER_ID_SORT, true); assertTrue(result.isEmpty()); List<Provider> providers = mockProviderListSPI(providerType, ELEMENTS_COUNT); providers.forEach(provider -> runtimeRegistry.registerProvider(provider)); result = runtimeRegistry.getProviders(0, 1000, RuntimeRegistry.PROVIDER_ID_SORT, true); for (Provider provider : providers) { assertTrue(result.contains(provider)); } }
@Override public List<Provider> getProviders(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Provider> values = providers.values(); return PageSortUtil.pageSort(values, (Provider p1, Provider p2) -> { switch (sort) { case PROVIDER_ID_SORT: return p1.getId().compareTo(p2.getId()); case PROVIDER_TYPE_NAME_SORT: return p1.getProviderType().getProviderTypeName().compareTo(p2.getProviderType().getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return p1.getProviderType().getVersion().compareTo(p2.getProviderType().getVersion()); default: return p1.toString().compareTo(p2.toString()); } }, page, pageSize, sort, sortOrder); }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<Provider> getProviders(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Provider> values = providers.values(); return PageSortUtil.pageSort(values, (Provider p1, Provider p2) -> { switch (sort) { case PROVIDER_ID_SORT: return p1.getId().compareTo(p2.getId()); case PROVIDER_TYPE_NAME_SORT: return p1.getProviderType().getProviderTypeName().compareTo(p2.getProviderType().getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return p1.getProviderType().getVersion().compareTo(p2.getProviderType().getVersion()); default: return p1.toString().compareTo(p2.toString()); } }, page, pageSize, sort, sortOrder); } }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<Provider> getProviders(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Provider> values = providers.values(); return PageSortUtil.pageSort(values, (Provider p1, Provider p2) -> { switch (sort) { case PROVIDER_ID_SORT: return p1.getId().compareTo(p2.getId()); case PROVIDER_TYPE_NAME_SORT: return p1.getProviderType().getProviderTypeName().compareTo(p2.getProviderType().getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return p1.getProviderType().getVersion().compareTo(p2.getProviderType().getVersion()); default: return p1.toString().compareTo(p2.toString()); } }, page, pageSize, sort, sortOrder); } InMemoryRuntimeRegistry(); }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<Provider> getProviders(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Provider> values = providers.values(); return PageSortUtil.pageSort(values, (Provider p1, Provider p2) -> { switch (sort) { case PROVIDER_ID_SORT: return p1.getId().compareTo(p2.getId()); case PROVIDER_TYPE_NAME_SORT: return p1.getProviderType().getProviderTypeName().compareTo(p2.getProviderType().getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return p1.getProviderType().getVersion().compareTo(p2.getProviderType().getVersion()); default: return p1.toString().compareTo(p2.toString()); } }, page, pageSize, sort, sortOrder); } InMemoryRuntimeRegistry(); @Override void registerProviderType(final ProviderType providerType); @Override List<ProviderType> getProviderTypes(final Integer page,
                                               final Integer pageSize,
                                               final String sort,
                                               final boolean sortOrder); @Override void deregisterProviderType(final ProviderType providerType); @Override void registerProvider(final Provider provider); @Override List<Provider> getProviders(final Integer page,
                                       final Integer pageSize,
                                       final String sort,
                                       final boolean sortOrder); @Override List<Provider> getProvidersByType(final ProviderType providerType); @Override Provider getProvider(final String providerId); @Override void deregisterProvider(final Provider provider); @Override void deregisterProvider(final String providerId); @Override void registerRuntime(final Runtime runtime); @Override List<Runtime> getRuntimes(final Integer page,
                                     final Integer pageSize,
                                     final String sort,
                                     final boolean sortOrder); @Override Runtime getRuntimeById(final String runtimeId); @Override void deregisterRuntime(final RuntimeId runtimeId); @Override Optional<T> getProvider(final ProviderId providerId,
                                                        final Class<T> clazz); }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<Provider> getProviders(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Provider> values = providers.values(); return PageSortUtil.pageSort(values, (Provider p1, Provider p2) -> { switch (sort) { case PROVIDER_ID_SORT: return p1.getId().compareTo(p2.getId()); case PROVIDER_TYPE_NAME_SORT: return p1.getProviderType().getProviderTypeName().compareTo(p2.getProviderType().getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return p1.getProviderType().getVersion().compareTo(p2.getProviderType().getVersion()); default: return p1.toString().compareTo(p2.toString()); } }, page, pageSize, sort, sortOrder); } InMemoryRuntimeRegistry(); @Override void registerProviderType(final ProviderType providerType); @Override List<ProviderType> getProviderTypes(final Integer page,
                                               final Integer pageSize,
                                               final String sort,
                                               final boolean sortOrder); @Override void deregisterProviderType(final ProviderType providerType); @Override void registerProvider(final Provider provider); @Override List<Provider> getProviders(final Integer page,
                                       final Integer pageSize,
                                       final String sort,
                                       final boolean sortOrder); @Override List<Provider> getProvidersByType(final ProviderType providerType); @Override Provider getProvider(final String providerId); @Override void deregisterProvider(final Provider provider); @Override void deregisterProvider(final String providerId); @Override void registerRuntime(final Runtime runtime); @Override List<Runtime> getRuntimes(final Integer page,
                                     final Integer pageSize,
                                     final String sort,
                                     final boolean sortOrder); @Override Runtime getRuntimeById(final String runtimeId); @Override void deregisterRuntime(final RuntimeId runtimeId); @Override Optional<T> getProvider(final ProviderId providerId,
                                                        final Class<T> clazz);  }