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

    IllegalArgumentException thrown =
        assertThrows(
            IllegalArgumentException.class,
            () ->
                FunctionDeclarationMaker.fromFunc(
                    FUNCTION_DESCRIPTION, function, STRING_PARAM_NAME));
    assertThat(thrown)
        .hasMessageThat()
        .isEqualTo(
            "The number of parameter names does not match the number of parameters in the method.");
  }
A function with invalid parameter type to test fromFunc.
java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/generativeai/FunctionDeclarationMakerTest.java