### Question:
BackgroundOverlay implements Observer, Overlay { @Override public void draw(Graphics graphics) { int index = 0; for (TileGeometry geometry : myModel.getGeometries()) { BoundingBox<? extends Position> bounds = (BoundingBox<? extends Position>)geometry.getBounds(); Vector3d upperLeft = bounds.getUpperLeft().asVector3d(); java.awt.Image image = myImages.get(index); double scaleFactor = myModel.getGeometryScaleFactors().get(index).doubleValue(); graphics.drawImage(image, (int)(upperLeft.getX() * scaleFactor), (int)(upperLeft.getY() * scaleFactor), null); index++; } } BackgroundOverlay(MapModel mapModel); @Override void close(); @Override void draw(Graphics graphics); @Override void update(Observable o, Object arg);  }### Answer:
@Test public void testDraw() { MapModel mapModel = new MapModel(); mapModel.setHeightWidth(150, 300); mapModel.setViewport(new ScreenBoundingBox(new ScreenPosition(0d, 0d), new ScreenPosition(300, 150))); BackgroundOverlay overlay = new BackgroundOverlay(mapModel); GraphicsMock graphics = new GraphicsMock(); overlay.draw(graphics); List<DrawnImage> drawnImages = graphics.getDrawnImages(); assertEquals(1, drawnImages.size()); DrawnImage drawn = drawnImages.get(0); assertEquals(0, drawn.getX()); assertEquals(0, drawn.getY()); assertNotNull(drawn.getImage()); assertEquals(150, drawn.getImage().getHeight(null)); assertEquals(300, drawn.getImage().getWidth(null)); }
@Test public void testDrawZoomed() { MapModel mapModel = new MapModel(); mapModel.setHeightWidth(150, 300); mapModel.setViewport(new ScreenBoundingBox(new ScreenPosition(150d, 75d), new ScreenPosition(300, 150))); BackgroundOverlay overlay = new BackgroundOverlay(mapModel); GraphicsMock graphics = new GraphicsMock(); overlay.draw(graphics); List<DrawnImage> drawnImages = graphics.getDrawnImages(); assertEquals(1, drawnImages.size()); DrawnImage drawn = drawnImages.get(0); assertEquals(-300, drawn.getX()); assertEquals(-150, drawn.getY()); assertNotNull(drawn.getImage()); assertEquals(300, drawn.getImage().getHeight(null)); assertEquals(600, drawn.getImage().getWidth(null)); }