### Question:
ContainerDBServiceProviderImpl implements ContainerDBServiceProvider { @Override public Map<Long, ContainerMetadata> getContainers(int limit, long prevContainer) throws IOException { Map<Long, ContainerMetadata> containers = new LinkedHashMap<>(); TableIterator<ContainerKeyPrefix, ? extends KeyValue<ContainerKeyPrefix, Integer>> containerIterator = containerKeyTable.iterator(); ContainerKeyPrefix seekKey; if (prevContainer > 0L) { seekKey = new ContainerKeyPrefix(prevContainer); KeyValue<ContainerKeyPrefix, Integer> seekKeyValue = containerIterator.seek(seekKey); if (seekKeyValue != null && seekKeyValue.getKey().getContainerId() != prevContainer) { return containers; } else { seekKey = new ContainerKeyPrefix(prevContainer + 1); containerIterator.seek(seekKey); } } while (containerIterator.hasNext()) { KeyValue<ContainerKeyPrefix, Integer> keyValue = containerIterator.next(); ContainerKeyPrefix containerKeyPrefix = keyValue.getKey(); Long containerID = containerKeyPrefix.getContainerId(); Integer numberOfKeys = keyValue.getValue(); if (containers.size() == limit && !containers.containsKey(containerID)) { break; } containers.computeIfAbsent(containerID, ContainerMetadata::new); ContainerMetadata containerMetadata = containers.get(containerID); containerMetadata.setNumberOfKeys(containerMetadata.getNumberOfKeys() + numberOfKeys); containers.put(containerID, containerMetadata); } return containers; } @Inject  ContainerDBServiceProviderImpl(DBStore dbStore,
                                        Configuration sqlConfiguration); @Override void close(); @Override void initNewContainerDB(Map<ContainerKeyPrefix, Integer>
                                     containerKeyPrefixCounts); @Override void storeContainerKeyMapping(ContainerKeyPrefix containerKeyPrefix,
                                       Integer count); @Override void storeContainerKeyCount(Long containerID, Long count); @Override long getKeyCountForContainer(Long containerID); @Override boolean doesContainerExists(Long containerID); @Override Integer getCountForContainerKeyPrefix(
      ContainerKeyPrefix containerKeyPrefix); @Override Map<ContainerKeyPrefix, Integer> getKeyPrefixesForContainer(
      long containerId); @Override Map<ContainerKeyPrefix, Integer> getKeyPrefixesForContainer(
      long containerId, String prevKeyPrefix); @Override Map<Long, ContainerMetadata> getContainers(int limit,
                                                    long prevContainer); @Override void deleteContainerMapping(ContainerKeyPrefix containerKeyPrefix); @Override long getCountForContainers(); @Override TableIterator getContainerTableIterator(); @Override void storeContainerCount(Long count); @Override void incrementContainerCountBy(long count);  }### Answer:
@Test public void testGetContainersWithPrevContainer() throws Exception { long containerId = 1L; long nextContainerId = 2L; populateKeysInContainers(containerId, nextContainerId); Map<Long, ContainerMetadata> containerMap = containerDbServiceProvider.getContainers(-1, 0L); assertEquals(2, containerMap.size()); assertEquals(3, containerMap.get(containerId).getNumberOfKeys()); assertEquals(3, containerMap.get(nextContainerId).getNumberOfKeys()); containerMap = containerDbServiceProvider.getContainers( 1, 0L); assertEquals(1, containerMap.size()); assertNull(containerMap.get(nextContainerId)); containerMap = containerDbServiceProvider.getContainers( -1, containerId); assertEquals(1, containerMap.size()); assertNull(containerMap.get(containerId)); containerMap = containerDbServiceProvider.getContainers( -1, nextContainerId); assertEquals(0, containerMap.size()); containerMap = containerDbServiceProvider.getContainers( -1, 10L); assertEquals(0, containerMap.size()); containerMap = containerDbServiceProvider.getContainers( 0, containerId); assertEquals(0, containerMap.size()); }