@Test
  public void fromValidJsonObject_returnsFunctionDeclaration()
      throws InvalidProtocolBufferException {
    JsonObject stringParamJsonObject = new JsonObject();
    stringParamJsonObject.addProperty("type", "STRING");
    stringParamJsonObject.addProperty("description", STRING_PARAM_NAME);

    JsonObject integerParamJsonObject = new JsonObject();
    integerParamJsonObject.addProperty("type", "INTEGER");
    integerParamJsonObject.addProperty("description", INTEGER_PARAM_NAME);

    JsonObject doubleParamJsonObject = new JsonObject();
    doubleParamJsonObject.addProperty("type", "NUMBER");
    doubleParamJsonObject.addProperty("description", DOUBLE_PARAM_NAME);

    JsonObject floatParamJsonObject = new JsonObject();
    floatParamJsonObject.addProperty("type", "NUMBER");
    floatParamJsonObject.addProperty("description", FLOAT_PARAM_NAME);

    JsonObject booleanParamJsonObject = new JsonObject();
    booleanParamJsonObject.addProperty("type", "BOOLEAN");
    booleanParamJsonObject.addProperty("description", BOOLEAN_PARAM_NAME);

    JsonObject propertiesJsonObject = new JsonObject();
    propertiesJsonObject.add(STRING_PARAM_NAME, stringParamJsonObject);
    propertiesJsonObject.add(INTEGER_PARAM_NAME, integerParamJsonObject);
    propertiesJsonObject.add(DOUBLE_PARAM_NAME, doubleParamJsonObject);
    propertiesJsonObject.add(FLOAT_PARAM_NAME, floatParamJsonObject);
    propertiesJsonObject.add(BOOLEAN_PARAM_NAME, booleanParamJsonObject);

    JsonObject parametersJsonObject = new JsonObject();
    parametersJsonObject.addProperty("type", "OBJECT");
    parametersJsonObject.add("properties", propertiesJsonObject);
    parametersJsonObject.add(
        "required", new Gson().toJsonTree(REQUIRED_PARAM_NAMES).getAsJsonArray());

    JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty("name", FUNCTION_NAME);
    jsonObject.addProperty("description", FUNCTION_DESCRIPTION);
    jsonObject.add("parameters", parametersJsonObject);

    FunctionDeclaration functionDeclaration = FunctionDeclarationMaker.fromJsonObject(jsonObject);

    assertThat(functionDeclaration).isEqualTo(EXPECTED_FUNCTION_DECLARATION);
  }
A function with invalid parameter type to test fromFunc.
java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/generativeai/FunctionDeclarationMakerTest.java