Search in sources :

Example 1 with GoogleApiTracer

use of org.apache.beam.sdk.extensions.gcp.options.GoogleApiDebugOptions.GoogleApiTracer in project beam by apache.

the class GoogleApiDebugOptionsTest method testMatchingAgainstClient.

@Test
public void testMatchingAgainstClient() throws Exception {
    GcsOptions options = PipelineOptionsFactory.as(GcsOptions.class);
    options.setGcpCredential(new TestCredential());
    options.setGoogleApiTrace(new GoogleApiTracer().addTraceFor(Transport.newStorageClient(options).build(), "TraceDestination"));
    Storage.Objects.Get getRequest = Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
    assertEquals("TraceDestination", getRequest.get("$trace"));
    Delete deleteRequest = GcpOptions.GcpTempLocationFactory.newCloudResourceManagerClient(options.as(CloudResourceManagerOptions.class)).build().projects().delete("testProjectId");
    assertNull(deleteRequest.get("$trace"));
}
Also used : Delete(com.google.api.services.cloudresourcemanager.CloudResourceManager.Projects.Delete) TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) GoogleApiTracer(org.apache.beam.sdk.extensions.gcp.options.GoogleApiDebugOptions.GoogleApiTracer) Test(org.junit.Test)

Example 2 with GoogleApiTracer

use of org.apache.beam.sdk.extensions.gcp.options.GoogleApiDebugOptions.GoogleApiTracer in project beam by apache.

the class GoogleApiDebugOptionsTest method testMatchingAgainstRequestType.

@Test
public void testMatchingAgainstRequestType() throws Exception {
    GcsOptions options = PipelineOptionsFactory.as(GcsOptions.class);
    options.setGcpCredential(new TestCredential());
    options.setGoogleApiTrace(new GoogleApiTracer().addTraceFor(Transport.newStorageClient(options).build().objects().get("aProjectId", "aObjectId"), "TraceDestination"));
    Storage.Objects.Get getRequest = Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
    assertEquals("TraceDestination", getRequest.get("$trace"));
    Storage.Objects.List listRequest = Transport.newStorageClient(options).build().objects().list("testProjectId");
    assertNull(listRequest.get("$trace"));
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) GoogleApiTracer(org.apache.beam.sdk.extensions.gcp.options.GoogleApiDebugOptions.GoogleApiTracer) Test(org.junit.Test)

Aggregations

TestCredential (org.apache.beam.sdk.extensions.gcp.auth.TestCredential)2 GoogleApiTracer (org.apache.beam.sdk.extensions.gcp.options.GoogleApiDebugOptions.GoogleApiTracer)2 Test (org.junit.Test)2 Delete (com.google.api.services.cloudresourcemanager.CloudResourceManager.Projects.Delete)1