### Question:
CollisionRaster { public final void setPixelIsNotTransparent(final int x, final int y) { data.set(computeIndex(x, y)); } CollisionRaster(final BufferedImage bufferedImage);  CollisionRaster(final Dimension dimension);  CollisionRaster(CollisionRaster other); final void setPixelIsNotTransparent(final int x, final int y); void mask(final CollisionRaster collisionRaster, final Point point); int nextNotTransparentPixel(final int minX, final int maxX, int y); boolean isTransparent(final int x, final int y); Dimension getDimension();  }### Answer:
@Test(expected = IllegalArgumentException.class) public void illegalX() { final Dimension dimension = new Dimension(90, 60); final CollisionRaster collisionRaster = new CollisionRaster(dimension); collisionRaster.setPixelIsNotTransparent(100, 0); }
@Test(expected = IllegalArgumentException.class) public void illegalY() { final Dimension dimension = new Dimension(90, 60); final CollisionRaster collisionRaster = new CollisionRaster(dimension); collisionRaster.setPixelIsNotTransparent(0, 70); }
@Test public void collisionsAreFound() { CollisionChecker checker = new RectanglePixelCollisionChecker(); final Dimension dimension = new Dimension(90, 60); final CollisionRaster collisionRasterA = new CollisionRaster(dimension); final CollisionRaster collisionRasterB = new CollisionRaster(dimension); for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { collisionRasterA.setPixelIsNotTransparent(20 + x, 20 + y); collisionRasterB.setPixelIsNotTransparent(30 + x, 30 + y); } } Assert.assertFalse(checker.collide( collidable(new Point(30, 30), dimension, collisionRasterA), collidable(new Point(30, 30), dimension, collisionRasterB) )); Assert.assertTrue(checker.collide( collidable(new Point(30, 30), dimension, collisionRasterA), collidable(new Point(20, 20), dimension, collisionRasterB) )); Assert.assertFalse(checker.collide( collidable(new Point(20, 20), dimension, collisionRasterA), collidable(new Point(30, 30), dimension, collisionRasterB) )); }