### Question:
Constants { static void checkIsPreview(final InputStream classInputStream) { if (classInputStream == null) { throw new IllegalStateException("Bytecode not available, can't check class version"); } int minorVersion; try (DataInputStream callerClassStream = new DataInputStream(classInputStream); ) { callerClassStream.readInt(); minorVersion = callerClassStream.readUnsignedShort(); } catch (IOException ioe) { throw new IllegalStateException("I/O error, can't check class version", ioe); } if (minorVersion != 0xFFFF) { throw new IllegalStateException( "ASM9_EXPERIMENTAL can only be used by classes compiled with --enable-preview"); } } private  Constants();   }### Answer:
@Test public void testCheckIsPreview_nullStream() { Executable checkIsPreview = () -> Constants.checkIsPreview(null); assertThrows(IllegalStateException.class, checkIsPreview); }
@Test public void testCheckIsPreview_invalidStream() { InputStream invalidStream = new ByteArrayInputStream(new byte[4]); Executable checkIsPreview = () -> Constants.checkIsPreview(invalidStream); assertThrows(IllegalStateException.class, checkIsPreview); }
@Test public void testCheckIsPreview_nonPreviewClass() { InputStream nonPreviewStream = new ByteArrayInputStream(new byte[8]); Executable checkIsPreview = () -> Constants.checkIsPreview(nonPreviewStream); assertThrows(IllegalStateException.class, checkIsPreview); }
@Test public void testCheckIsPreview_previewClass() { byte[] previewClass = new byte[] {0, 0, 0, 0, (byte) 0xFF, (byte) 0xFF}; InputStream previewStream = new ByteArrayInputStream(previewClass); Executable checkIsPreview = () -> Constants.checkIsPreview(previewStream); assertDoesNotThrow(checkIsPreview); }