### Question:
OblongGridBuilder extends AbstractGridBuilder { @Override public Oblong createNeighbor(GridElement el, Neighbor neighbor) { if (el == null || neighbor == null) { throw new IllegalArgumentException( "el and neighbour position must both be non-null"); } if (!(el instanceof Oblong)) { throw new IllegalArgumentException("el must be an instance of Oblong"); } Oblong oblong = (Oblong) el; ReferencedEnvelope bounds = oblong.getBounds(); double dx, dy; switch (neighbor) { case LEFT: dx = -bounds.getWidth(); dy = 0.0; break; case LOWER: dx = 0.0; dy = -bounds.getHeight(); break; case LOWER_LEFT: dx = -bounds.getWidth(); dy = -bounds.getHeight(); break; case LOWER_RIGHT: dx = bounds.getWidth(); dy = -bounds.getHeight(); break; case RIGHT: dx = bounds.getWidth(); dy = 0.0; break; case UPPER: dx = 0.0; dy = bounds.getHeight(); break; case UPPER_LEFT: dx = -bounds.getWidth(); dy = bounds.getHeight(); break; case UPPER_RIGHT: dx = bounds.getWidth(); dy = bounds.getHeight(); break; default: throw new IllegalArgumentException("Unrecognized value for neighbor"); } return Oblongs.create(bounds.getMinX() + dx, bounds.getMinY() + dy, bounds.getWidth(), bounds.getHeight(), bounds.getCoordinateReferenceSystem()); } OblongGridBuilder(ReferencedEnvelope bounds, double width, double height); @Override boolean isValidNeighbor(Neighbor neighbor); @Override Oblong createNeighbor(GridElement el, Neighbor neighbor); @Override boolean isValidDenseVertexSpacing(double v); @Override GridElement getFirstElement(); @Override GridElement getNextXElement(GridElement el); @Override GridElement getNextYElement(GridElement el);  }### Answer:
@Test public void createNeighbor() { Oblong neighbor = null; class Shift { double dx; double dy; public Shift(double dx, double dy) { this.dx = dx; this.dy = dy; } } Map<Neighbor, Shift> shifts = new HashMap<Neighbor, Shift>(); shifts.put(Neighbor.LOWER, new Shift(0.0, -HEIGHT)); shifts.put(Neighbor.LOWER_LEFT, new Shift(-WIDTH, -HEIGHT)); shifts.put(Neighbor.LOWER_RIGHT, new Shift(WIDTH, -HEIGHT)); shifts.put(Neighbor.LEFT, new Shift(-WIDTH, 0.0)); shifts.put(Neighbor.RIGHT, new Shift(WIDTH, 0.0)); shifts.put(Neighbor.UPPER, new Shift(0.0, HEIGHT)); shifts.put(Neighbor.UPPER_LEFT, new Shift(-WIDTH, HEIGHT)); shifts.put(Neighbor.UPPER_RIGHT, new Shift(WIDTH, HEIGHT)); Oblong oblong = Oblongs.create(0.0, 0.0, WIDTH, HEIGHT, null); for (Neighbor n : Neighbor.values()) { neighbor = gridBuilder.createNeighbor(oblong, n); Shift shift = shifts.get(n); assertNotNull("Error in test code", shift); assertNeighbor(oblong, neighbor, shift.dx, shift.dy); } }