@Test public void testGetProviderTypes() { List<ProviderType> result = runtimeRegistry.getProviderTypes(0, 1000, RuntimeRegistry.PROVIDER_TYPE_NAME_SORT, true); assertTrue(result.isEmpty()); List<ProviderType> providerTypes = mockProviderTypeListSPI(ELEMENTS_COUNT); providerTypes.forEach(providerType -> runtimeRegistry.registerProviderType(providerType)); result = runtimeRegistry.getProviderTypes(0, 1000, RuntimeRegistry.PROVIDER_TYPE_NAME_SORT, true); for (ProviderType providerType : providerTypes) { assertTrue(result.contains(providerType)); } }
@Override public List<ProviderType> getProviderTypes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<ProviderType> values = providerTypes.values(); return PageSortUtil.pageSort(values, (ProviderType pt1, ProviderType pt2) -> { switch (sort) { case PROVIDER_TYPE_NAME_SORT: return pt1.getProviderTypeName().compareTo(pt2.getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return pt1.getVersion().compareTo(pt2.getVersion()); default: return pt1.toString().compareTo(pt2.toString()); } }, page, pageSize, sort, sortOrder); }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<ProviderType> getProviderTypes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<ProviderType> values = providerTypes.values(); return PageSortUtil.pageSort(values, (ProviderType pt1, ProviderType pt2) -> { switch (sort) { case PROVIDER_TYPE_NAME_SORT: return pt1.getProviderTypeName().compareTo(pt2.getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return pt1.getVersion().compareTo(pt2.getVersion()); default: return pt1.toString().compareTo(pt2.toString()); } }, page, pageSize, sort, sortOrder); } }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<ProviderType> getProviderTypes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<ProviderType> values = providerTypes.values(); return PageSortUtil.pageSort(values, (ProviderType pt1, ProviderType pt2) -> { switch (sort) { case PROVIDER_TYPE_NAME_SORT: return pt1.getProviderTypeName().compareTo(pt2.getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return pt1.getVersion().compareTo(pt2.getVersion()); default: return pt1.toString().compareTo(pt2.toString()); } }, page, pageSize, sort, sortOrder); } InMemoryRuntimeRegistry(); }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<ProviderType> getProviderTypes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<ProviderType> values = providerTypes.values(); return PageSortUtil.pageSort(values, (ProviderType pt1, ProviderType pt2) -> { switch (sort) { case PROVIDER_TYPE_NAME_SORT: return pt1.getProviderTypeName().compareTo(pt2.getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return pt1.getVersion().compareTo(pt2.getVersion()); default: return pt1.toString().compareTo(pt2.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<ProviderType> getProviderTypes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<ProviderType> values = providerTypes.values(); return PageSortUtil.pageSort(values, (ProviderType pt1, ProviderType pt2) -> { switch (sort) { case PROVIDER_TYPE_NAME_SORT: return pt1.getProviderTypeName().compareTo(pt2.getProviderTypeName()); case PROVIDER_TYPE_VERSION_SORT: return pt1.getVersion().compareTo(pt2.getVersion()); default: return pt1.toString().compareTo(pt2.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);  }