public static RunnerApi.Pipeline toProto(Pipeline pipeline) {
    return toProto(pipeline, SdkComponents.create(pipeline.getOptions()));
  }
@Test
  public void testResourceHints() {
    Pipeline pipeline = Pipeline.create();
    PCollection<byte[]> root = pipeline.apply(Impulse.create());
    ParDo.SingleOutput<byte[], byte[]> transform = ParDo.of(new IdentityDoFn<byte[]>());
    root.apply("Big", transform.setResourceHints(ResourceHints.create().withMinRam("640KB")));
    root.apply("Small", transform.setResourceHints(ResourceHints.create().withMinRam(1)));
    root.apply(
        "AnotherBig", transform.setResourceHints(ResourceHints.create().withMinRam("640KB")));
    RunnerApi.Pipeline pipelineProto = PipelineTranslation.toProto(pipeline, false);
    assertThat(
        pipelineProto
            .getComponents()
            .getEnvironmentsMap()
            .get(getLeafTransform(pipelineProto, "Big").getEnvironmentId())
            .getResourceHintsMap(),
        org.hamcrest.Matchers.hasEntry(
            "beam:resources:min_ram_bytes:v1", ByteString.copyFromUtf8("640000")));
    assertThat(
        pipelineProto
            .getComponents()
            .getEnvironmentsMap()
            .get(getLeafTransform(pipelineProto, "Small").getEnvironmentId())
            .getResourceHintsMap(),
        org.hamcrest.Matchers.hasEntry(
            "beam:resources:min_ram_bytes:v1", ByteString.copyFromUtf8("1")));
    // Ensure we re-use environments.
    assertThat(
        getLeafTransform(pipelineProto, "Big").getEnvironmentId(),
        equalTo(getLeafTransform(pipelineProto, "AnotherBig").getEnvironmentId()));
  }