Search in sources :

Example 1 with ApiSurface

use of org.apache.beam.sdk.util.ApiSurface in project beam by apache.

the class GcpApiSurfaceTest method testGcpApiSurface.

@Test
public void testGcpApiSurface() throws Exception {
    final Package thisPackage = getClass().getPackage();
    final ClassLoader thisClassLoader = getClass().getClassLoader();
    final ApiSurface apiSurface = ApiSurface.ofPackage(thisPackage, thisClassLoader).pruningPattern(BigqueryMatcher.class.getName()).pruningPattern("org[.]apache[.]beam[.].*Test.*").pruningPattern("org[.]apache[.]beam[.].*IT").pruningPattern("java[.]lang.*").pruningPattern("java[.]util.*");
    @SuppressWarnings("unchecked") final Set<Matcher<Class<?>>> allowedClasses = ImmutableSet.of(classesInPackage("com.google.api.client.googleapis"), classesInPackage("com.google.api.client.http"), classesInPackage("com.google.api.client.json"), classesInPackage("com.google.api.client.util"), classesInPackage("com.google.api.services.bigquery.model"), classesInPackage("com.google.auth"), classesInPackage("com.google.bigtable.v2"), classesInPackage("com.google.cloud.bigtable.config"), Matchers.<Class<?>>equalTo(com.google.cloud.bigtable.grpc.BigtableClusterName.class), Matchers.<Class<?>>equalTo(com.google.cloud.bigtable.grpc.BigtableInstanceName.class), Matchers.<Class<?>>equalTo(com.google.cloud.bigtable.grpc.BigtableTableName.class), Matchers.<Class<?>>equalTo(com.google.cloud.ByteArray.class), Matchers.<Class<?>>equalTo(com.google.cloud.Date.class), Matchers.<Class<?>>equalTo(com.google.cloud.Timestamp.class), classesInPackage("com.google.cloud.spanner"), classesInPackage("com.google.datastore.v1"), classesInPackage("com.google.protobuf"), classesInPackage("com.google.type"), classesInPackage("com.fasterxml.jackson.annotation"), classesInPackage("com.fasterxml.jackson.core"), classesInPackage("com.fasterxml.jackson.databind"), classesInPackage("io.grpc"), classesInPackage("java"), classesInPackage("javax"), classesInPackage("org.apache.beam"), classesInPackage("org.apache.commons.logging"), classesInPackage("org.joda.time"));
    assertThat(apiSurface, containsOnlyClassesMatching(allowedClasses));
}
Also used : BigqueryMatcher(org.apache.beam.sdk.io.gcp.testing.BigqueryMatcher) Matcher(org.hamcrest.Matcher) BigqueryMatcher(org.apache.beam.sdk.io.gcp.testing.BigqueryMatcher) ApiSurface(org.apache.beam.sdk.util.ApiSurface) ApiSurface.classesInPackage(org.apache.beam.sdk.util.ApiSurface.classesInPackage) Test(org.junit.Test)

Example 2 with ApiSurface

use of org.apache.beam.sdk.util.ApiSurface in project beam by apache.

the class DirectRunnerApiSurfaceTest method testDirectRunnerApiSurface.

@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).pruningClass(Pipeline.class).pruningClass(PipelineRunner.class).pruningClass(PipelineOptions.class).pruningClass(PipelineOptionsRegistrar.class).pruningClass(PipelineOptions.DirectRunner.class).pruningClass(DisplayData.Builder.class).pruningClass(MetricResults.class).pruningPattern("org[.]apache[.]beam[.].*Test.*").pruningPattern("org[.]apache[.]beam[.].*IT").pruningPattern("java[.]io.*").pruningPattern("java[.]lang.*").pruningPattern("java[.]util.*");
    assertThat(apiSurface, containsOnlyPackages(allowed));
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) ApiSurface(org.apache.beam.sdk.util.ApiSurface) MetricResults(org.apache.beam.sdk.metrics.MetricResults) DisplayData(org.apache.beam.sdk.transforms.display.DisplayData) Pipeline(org.apache.beam.sdk.Pipeline) Test(org.junit.Test)

Aggregations

ApiSurface (org.apache.beam.sdk.util.ApiSurface)2 Test (org.junit.Test)2 Pipeline (org.apache.beam.sdk.Pipeline)1 BigqueryMatcher (org.apache.beam.sdk.io.gcp.testing.BigqueryMatcher)1 MetricResults (org.apache.beam.sdk.metrics.MetricResults)1 PipelineOptions (org.apache.beam.sdk.options.PipelineOptions)1 DisplayData (org.apache.beam.sdk.transforms.display.DisplayData)1 ApiSurface.classesInPackage (org.apache.beam.sdk.util.ApiSurface.classesInPackage)1 Matcher (org.hamcrest.Matcher)1