### Question:
ImageData implements Serializable { public static ImageData from(Common.ImageData sc2ApiImageData) { require("sc2api image data", sc2ApiImageData); return new ImageData(sc2ApiImageData); } private  ImageData(Common.ImageData sc2ApiImageData); static ImageData from(Common.ImageData sc2ApiImageData); int getBitsPerPixel(); Size2dI getSize(); @JsonIgnore byte[] getData(); @JsonIgnore BufferedImage getImage(); int sample(Point2d point, Origin origin); int sample(Point2d point); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test void throwsExceptionWhenSc2ApiImageDataIsNull() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(nothing())) .withMessage("sc2api image data is required"); }
@Test void convertsAllFieldsFromSc2ApiImageData() { assertThatAllFieldsAreConverted(ImageData.from(sc2ApiImageData())); }
@Test void throwsExceptionWhenBitsPerPixelIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(without( () -> sc2ApiImageData().toBuilder(), Common.ImageData.Builder::clearBitsPerPixel).build())) .withMessage("bits per pixel is required"); }
@Test void throwsExceptionWhenSizeIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(without( () -> sc2ApiImageData().toBuilder(), Common.ImageData.Builder::clearSize).build())) .withMessage("size is required"); }
@Test void throwsExceptionWhenImageIsNotProvided() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(without( () -> sc2ApiImageData().toBuilder(), Common.ImageData.Builder::clearData).build())) .withMessage("data is required"); }
@Test void throwsExceptionWhenImageSizeIsInvalid() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(corruptedSc2ApiImageData())) .withMessage("expected image size [4096] is not equal actual size [1]"); }
@Test void throwsExceptionWhenImageTypeIsUnsupported() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> ImageData.from(sc2ApiImageDataWithTwoBitPerPixel())) .withMessage("Unsupported image type with bits per pixel [2]. Expected {1, 8, 24, 32}."); }