### Question:
ModelData implements AutoCloseable { public static ModelData fromOnnxFile(String onnxModelPath) throws MenohException { final PointerByReference handle = new PointerByReference(); checkError(MenohNative.INSTANCE.menoh_make_model_data_from_onnx(onnxModelPath, handle)); return new ModelData(handle.getValue()); } private  ModelData(Pointer handle); ModelData optimize(VariableProfileTable vpt); @Override void close(); static ModelData fromOnnxFile(String onnxModelPath);  }### Answer:
@Test public void makeFromUnsupportedOnnxOpsetVersionFile() throws Exception { final String path = getResourceFilePath("models/unsupported_onnx_opset_version.onnx"); MenohException e = assertThrows(MenohException.class, () -> ModelData.fromOnnxFile(path)); assertAll("invalid onnx file", () -> assertEquals(ErrorCode.UNSUPPORTED_ONNX_OPSET_VERSION, e.getErrorCode()), () -> assertEquals( String.format( "menoh unsupported onnx opset version error: %s has " + "onnx opset version %d > %d (unsupported_onnx_opset_version)", path, 127, 7), e.getMessage()) ); }
@Test public void makeFromNonExistentOnnxFile() { MenohException e = assertThrows( MenohException.class, () -> ModelData.fromOnnxFile("__NON_EXISTENT_FILENAME__")); assertAll("non-existent onnx file", () -> assertEquals(ErrorCode.INVALID_FILENAME, e.getErrorCode()), () -> assertEquals( "menoh invalid filename error: __NON_EXISTENT_FILENAME__ (invalid_filename)", e.getMessage()) ); }
@Test public void makeFromInvalidOnnxFile() throws Exception { final String path = getResourceFilePath("models/invalid_format.onnx"); MenohException e = assertThrows(MenohException.class, () -> ModelData.fromOnnxFile(path)); assertAll("invalid onnx file", () -> assertEquals(ErrorCode.ONNX_PARSE_ERROR, e.getErrorCode()), () -> assertEquals( String.format("menoh onnx parse error: %s (onnx_parse_error)", path), e.getMessage()) ); }