static <T, V> ThrowingFunction<KV<T, V>, KV<T, String>> createToStringFunctionForPTransform(
      String ptransformId, PTransform pTransform) {
    return (KV<T, V> input) -> KV.of(input.getKey(), Objects.toString(input.getValue()));
  }
@Test
  public void testToStringOverride() throws Exception {
    class ClassWithToStringOverride {
      @Override
      public String toString() {
        return "Some string";
      }
    }

    String pTransformId = "pTransformId";

    SdkComponents components = SdkComponents.create();
    components.registerEnvironment(Environments.createDockerEnvironment("java"));
    RunnerApi.PTransform pTransform = RunnerApi.PTransform.newBuilder().build();

    ThrowingFunction<KV<String, ClassWithToStringOverride>, KV<String, String>> toStringFunction =
        ToStringFnRunner.createToStringFunctionForPTransform(pTransformId, pTransform);

    KV<String, ClassWithToStringOverride> input = KV.of("key", new ClassWithToStringOverride());

    assertEquals(KV.of("key", "Some string"), toStringFunction.apply(input));
  }