public static ViewFn<?, ?> viewFnFromProto(RunnerApi.FunctionSpec viewFn)
      throws InvalidProtocolBufferException {
    RunnerApi.FunctionSpec spec = viewFn;
    checkArgument(
        spec.getUrn().equals(ParDoTranslation.CUSTOM_JAVA_VIEW_FN_URN),
        "Can't deserialize unknown %s type %s",
        ViewFn.class.getSimpleName(),
        spec.getUrn());
    return (ViewFn<?, ?>)
        SerializableUtils.deserializeFromByteArray(
            spec.getPayload().toByteArray(), "Custom ViewFn");
  }
@Test
  public void testViewFnTranslation() throws Exception {
    SdkComponents sdkComponents = SdkComponents.create();
    sdkComponents.registerEnvironment(Environments.createDockerEnvironment("java"));
    assertEquals(
        new TestViewFn(),
        PCollectionViewTranslation.viewFnFromProto(
            ParDoTranslation.translateViewFn(new TestViewFn(), sdkComponents)));
  }