@Test public void testGetRuntimes() { List<Runtime> result = runtimeRegistry.getRuntimes(0, 1000, RuntimeRegistry.RUNTIME_ID_SORT, true); assertTrue(result.isEmpty()); List<Runtime> runtimes = mockRuntimeList(providerId, "", ELEMENTS_COUNT); runtimes.forEach(runtime -> runtimeRegistry.registerRuntime(runtime)); result = runtimeRegistry.getRuntimes(0, 1000, RuntimeRegistry.RUNTIME_ID_SORT, true); for (Runtime runtime : runtimes) { assertTrue(result.contains(runtime)); } }
@Override public List<Runtime> getRuntimes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Runtime> values = runtimes.values(); return PageSortUtil.pageSort(values, (Runtime r1, Runtime r2) -> { switch (sort) { case RUNTIME_ID_SORT: return r1.getId().compareTo(r2.getId()); case RUNTIME_STATE_SORT: return r1.getState().getState().compareTo(r2.getState().getState()); default: return r1.toString().compareTo(r2.toString()); } }, page, pageSize, sort, sortOrder); }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<Runtime> getRuntimes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Runtime> values = runtimes.values(); return PageSortUtil.pageSort(values, (Runtime r1, Runtime r2) -> { switch (sort) { case RUNTIME_ID_SORT: return r1.getId().compareTo(r2.getId()); case RUNTIME_STATE_SORT: return r1.getState().getState().compareTo(r2.getState().getState()); default: return r1.toString().compareTo(r2.toString()); } }, page, pageSize, sort, sortOrder); } }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<Runtime> getRuntimes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Runtime> values = runtimes.values(); return PageSortUtil.pageSort(values, (Runtime r1, Runtime r2) -> { switch (sort) { case RUNTIME_ID_SORT: return r1.getId().compareTo(r2.getId()); case RUNTIME_STATE_SORT: return r1.getState().getState().compareTo(r2.getState().getState()); default: return r1.toString().compareTo(r2.toString()); } }, page, pageSize, sort, sortOrder); } InMemoryRuntimeRegistry(); }
InMemoryRuntimeRegistry implements RuntimeRegistry { @Override public List<Runtime> getRuntimes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Runtime> values = runtimes.values(); return PageSortUtil.pageSort(values, (Runtime r1, Runtime r2) -> { switch (sort) { case RUNTIME_ID_SORT: return r1.getId().compareTo(r2.getId()); case RUNTIME_STATE_SORT: return r1.getState().getState().compareTo(r2.getState().getState()); default: return r1.toString().compareTo(r2.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<Runtime> getRuntimes(final Integer page, final Integer pageSize, final String sort, final boolean sortOrder) { final Collection<Runtime> values = runtimes.values(); return PageSortUtil.pageSort(values, (Runtime r1, Runtime r2) -> { switch (sort) { case RUNTIME_ID_SORT: return r1.getId().compareTo(r2.getId()); case RUNTIME_STATE_SORT: return r1.getState().getState().compareTo(r2.getState().getState()); default: return r1.toString().compareTo(r2.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);  }