@Test
  public void fromFuncWithoutParameterNamesWithoutReflection_throwsIllegalStateException()
      throws NoSuchMethodException {
    Method function =
        FunctionDeclarationMakerTest.class.getMethod(
            FUNCTION_NAME, String.class, int.class, double.class, float.class, boolean.class);

    IllegalStateException thrown =
        assertThrows(
            IllegalStateException.class,
            () -> FunctionDeclarationMaker.fromFunc(FUNCTION_DESCRIPTION, function));
    assertThat(thrown)
        .hasMessageThat()
        .isEqualTo(
            "Failed to retrieve the parameter name from reflection. Please compile your"
                + " code with  \"-parameters\" flag or use `fromFunc(String, Method,"
                + " String...)` to manually enter parameter names");
  }
A function with invalid parameter type to test fromFunc.
java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/generativeai/FunctionDeclarationMakerTest.java