### Question:
MapTileListBorderComputer implements MapTileListComputer { @Override public MapTileList computeFromSource(final MapTileList pSource, final MapTileList pReuse) { final MapTileList out = pReuse != null ? pReuse : new MapTileList(); for (int i = 0 ; i < pSource.getSize() ; i ++) { final long sourceIndex = pSource.get(i); final int zoom = MapTileIndex.getZoom(sourceIndex); final int sourceX = MapTileIndex.getX(sourceIndex); final int sourceY = MapTileIndex.getY(sourceIndex); final int power = 1 << zoom; for (int j = -mBorder ; j <= mBorder ; j ++) { for (int k = -mBorder ; k <= mBorder ; k ++) { int destX = sourceX + j; int destY = sourceY + k; while (destX < 0) { destX += power; } while (destY < 0) { destY += power; } while (destX >= power) { destX -= power; } while (destY >= power) { destY -= power; } final long index = MapTileIndex.getTileIndex(zoom, destX, destY); if (out.contains(index)) { continue; } if (pSource.contains(index) && !mIncludeAll) { continue; } out.put(index); } } } return out; } MapTileListBorderComputer(final int pBorder, final boolean pIncludeAll); int getBorder(); boolean isIncludeAll(); @Override MapTileList computeFromSource(final MapTileList pSource, final MapTileList pReuse);  }### Answer:
@Test public void testOnePointModuloInclude() { final MapTileList source = new MapTileList(); final MapTileList dest = new MapTileList(); final Set<Long> set = new HashSet<>(); final int border = 2; final MapTileListBorderComputer computer = new MapTileListBorderComputer(border, true); final int zoom = 5; final int sourceX = 1; final int sourceY = 31; source.put(MapTileIndex.getTileIndex(zoom, sourceX, sourceY)); add(set, zoom, sourceX, sourceY, border); computer.computeFromSource(source, dest); check(dest, set, zoom); }
@Test public void testOnePointModulo() { final MapTileList source = new MapTileList(); final MapTileList dest = new MapTileList(); final Set<Long> set = new HashSet<>(); final int border = 2; final MapTileListBorderComputer computer = new MapTileListBorderComputer(border, false); final int zoom = 5; final int sourceX = 1; final int sourceY = 31; source.put(MapTileIndex.getTileIndex(zoom, sourceX, sourceY)); add(set, zoom, sourceX, sourceY, border); set.remove(MapTileIndex.getTileIndex(zoom, sourceX, sourceY)); computer.computeFromSource(source, dest); check(dest, set, zoom); }
@Test public void testTwoContiguousPointsModuloInclude() { final MapTileList source = new MapTileList(); final MapTileList dest = new MapTileList(); final Set<Long> set = new HashSet<>(); final int border = 2; final MapTileListBorderComputer computer = new MapTileListBorderComputer(border, true); final int zoom = 5; final int sourceX = 1; final int sourceY = 31; source.put(MapTileIndex.getTileIndex(zoom, sourceX, sourceY)); source.put(MapTileIndex.getTileIndex(zoom, sourceX + 1, sourceY)); add(set, zoom, sourceX, sourceY, border); add(set, zoom, sourceX + 1, sourceY, border); computer.computeFromSource(source, dest); check(dest, set, zoom); }