/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.beam.runners.direct;

import static org.apache.beam.sdk.util.ApiSurface.containsOnlyPackages;
import static org.junit.Assert.assertThat;

import com.google.common.collect.ImmutableSet;
import java.util.Set;
import javax.annotation.Nullable;
import org.apache.beam.sdk.util.ApiSurface;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** API surface verification for {@link org.apache.beam.runners.direct}. */
@RunWith(JUnit4.class)
public class DirectRunnerApiSurfaceTest {
  @Test
  public void testDirectRunnerApiSurface() throws Exception {
    // The DirectRunner can expose the Core SDK, anything exposed by the Core SDK, and itself
    @SuppressWarnings("unchecked")
    final Set<String> allowed =
        ImmutableSet.of("org.apache.beam.sdk", "org.apache.beam.runners.direct", "org.joda.time");

    final Package thisPackage = getClass().getPackage();
    final ClassLoader thisClassLoader = getClass().getClassLoader();
    ApiSurface apiSurface =
        ApiSurface.ofPackage(thisPackage, thisClassLoader)
            .pruningPattern("org[.]apache[.]beam[.].*Test.*")
            .pruningPattern("org[.]apache[.]beam[.].*IT")
            .pruningClass(Nullable.class)
            .pruningPattern("java[.]io.*")
            .pruningPattern("java[.]lang.*")
            .pruningPattern("java[.]util.*");

    assertThat(apiSurface, containsOnlyPackages(allowed));
  }
}

@@ -1037,33 +1037,301 @@
 ort 
-javax.annotation.Nullable
+org.apache.beam.sdk.Pipeline;%0Aimport org.apache.beam.sdk.PipelineRunner;%0Aimport org.apache.beam.sdk.metrics.MetricResults;%0Aimport org.apache.beam.sdk.options.PipelineOptions;%0Aimport org.apache.beam.sdk.options.PipelineOptionsRegistrar;%0Aimport org.apache.beam.sdk.transforms.display.DisplayData
 ;%0Aim
@@ -2147,16 +2147,567 @@
 Loader)%0A
+            // Do not include dependencies that are required based on the known exposures. This%0A            // could alternatively prune everything exposed by the public parts of the Core SDK%0A            .pruningClass(Pipeline.class)%0A            .pruningClass(PipelineRunner.class)%0A            .pruningClass(PipelineOptions.class)%0A            .pruningClass(PipelineOptionsRegistrar.class)%0A            .pruningClass(PipelineOptions.DirectRunner.class)%0A            .pruningClass(DisplayData.Builder.class)%0A            .pruningClass(MetricResults.class)%0A
         
@@ -2822,50 +2822,8 @@
 T%22)%0A
-            .pruningClass(Nullable.class)%0A
     

Improve Pruning performed by the DirectRunnerApiSurfaceTest