@Deprecated
  public static <ElemT, ViewT> PCollectionView<ViewT> getView(
      AppliedPTransform<
              PCollection<ElemT>,
              PCollection<ElemT>,
              PTransform<PCollection<ElemT>, PCollection<ElemT>>>
          application)
      throws IOException {

    RunnerApi.PTransform transformProto =
        PTransformTranslation.toProto(
            application,
            Collections.emptyList(),
            SdkComponents.create(application.getPipeline().getOptions()));

    checkArgument(
        PTransformTranslation.CREATE_VIEW_TRANSFORM_URN.equals(transformProto.getSpec().getUrn()),
        "Illegal attempt to extract %s from transform %s with name \"%s\" and URN \"%s\"",
        PCollectionView.class.getSimpleName(),
        application.getTransform(),
        application.getFullName(),
        transformProto.getSpec().getUrn());

    return (PCollectionView<ViewT>)
        SerializableUtils.deserializeFromByteArray(
            transformProto.getSpec().getPayload().toByteArray(),
            PCollectionView.class.getSimpleName());
  }
@Test
  public void testExtractionDirectFromTransform() throws Exception {
    SdkComponents components = SdkComponents.create();
    components.registerEnvironment(Environments.createDockerEnvironment("java"));
    components.registerPCollection(testPCollection);

    AppliedPTransform<?, ?, ?> appliedPTransform =
        AppliedPTransform.of(
            "foo",
            PValues.expandInput(testPCollection),
            PValues.expandOutput(createViewTransform.getView()),
            createViewTransform,
            ResourceHints.create(),
            p);

    CreatePCollectionViewTranslation.getView((AppliedPTransform) appliedPTransform);

    FunctionSpec payload = PTransformTranslation.toProto(appliedPTransform, components).getSpec();

    // Checks that the payload is what it should be
    PCollectionView<?> deserializedView =
        (PCollectionView<?>)
            SerializableUtils.deserializeFromByteArray(
                payload.getPayload().toByteArray(), PCollectionView.class.getSimpleName());

    assertThat(deserializedView, Matchers.equalTo(createViewTransform.getView()));
  }