### Question:
GlassImpl implements Glass { public void drop(Figure figure, int x, int y) { if (isOutside(figure, x, y)) { return; } int available = findAvailableYPosition(figure, x, y); if (available >= height) { return; } performDrop(figure, x, available - figure.bottom()); removeLines(); } GlassImpl(int width, int height, Supplier<Integer> supplier); boolean accept(Figure figure, int x, int y); void drop(Figure figure, int x, int y); void empty(); @Override void figureAt(Figure figure, int x, int y); @Override List<Plot> dropped(); @Override List<Plot> currentFigure(); @Override boolean isEmpty(); @Override void setListener(EventListener listener); @Override Glass clone(); static final int BITS; static final BigInteger Ob111; }### Answer:
@Test public void shouldNotifyWhenLineRemoved() { glass.drop(glassWidthFigure, 0, HEIGHT); verify(listener).event(Events.linesRemoved(1, 1)); }
@Test public void shouldNotifyWhenSeveralLinesRemoved() { glass.drop(line9Width, 0, HEIGHT); glass.drop(line9Width, 0, HEIGHT); glass.drop(new FigureImpl(0, 0, "#", "#"), WIDTH - 1, HEIGHT); verify(listener).event(Events.linesRemoved(1, 2)); }
@Test public void shouldNotifyScoreBoardWhenDropped() { glass.drop(point, 0, HEIGHT); verify(listener).event(Events.figuresDropped(1, point.type().getColor().index())); }
@Test public void shouldNotifyAllListenersScoreBoardWhenDropped() { glass.drop(point, 0, HEIGHT); verify(listener).event(Events.figuresDropped(1, point.type().getColor().index())); }
@Test public void shouldNotifyAllListenersScoreBoardWhenLinesRemoved() { glass.drop(glassWidthFigure, 0, HEIGHT); verify(listener).event(Events.figuresDropped(1, glassWidthFigure.type().getColor().index())); }
@Test public void shouldQuietWhenDropOutOfBounds() { glass.drop(createVerticalFigure(HEIGHT), WIDTH / 2, HEIGHT); try { glass.drop(Type.I.create(), WIDTH / 2, HEIGHT); verify(listener, times(1)).event(Events.figuresDropped(1, Type.I.getColor().index())); } catch (Exception e) { fail("Was exception: " + e); } }