use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project gapic-generator-java by googleapis.
the class ConfigClientTest method createExclusionTest4.
@Test
public void createExclusionTest4() throws Exception {
LogExclusion expectedResponse = LogExclusion.newBuilder().setName(LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]").toString()).setDescription("description-1724546052").setFilter("filter-1274492040").setDisabled(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
mockConfigServiceV2.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
LogExclusion exclusion = LogExclusion.newBuilder().build();
LogExclusion actualResponse = client.createExclusion(parent, exclusion);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateExclusionRequest actualRequest = ((CreateExclusionRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(exclusion, actualRequest.getExclusion());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project gapic-generator-java by googleapis.
the class LoggingClientTest method listLogsExceptionTest4.
@Test
public void listLogsExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLoggingServiceV2.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
client.listLogs(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project gapic-generator-java by googleapis.
the class SyncCreateLogMetricProjectnameLogmetric method syncCreateLogMetricProjectnameLogmetric.
public static void syncCreateLogMetricProjectnameLogmetric() throws Exception {
// It may require modifications to work in your environment.
try (MetricsClient metricsClient = MetricsClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
LogMetric metric = LogMetric.newBuilder().build();
LogMetric response = metricsClient.createLogMetric(parent, metric);
}
}
use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project gapic-generator-java by googleapis.
the class SyncCreateSinkProjectnameLogsink method syncCreateSinkProjectnameLogsink.
public static void syncCreateSinkProjectnameLogsink() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
LogSink sink = LogSink.newBuilder().build();
LogSink response = configClient.createSink(parent, sink);
}
}
use of com.google.cloud.bigquery.datatransfer.v1.ProjectName in project gapic-generator-java by googleapis.
the class SubscriptionAdminClientTest method listSnapshotsTest.
@Test
public void listSnapshotsTest() throws Exception {
Snapshot responsesElement = Snapshot.newBuilder().build();
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.of("[PROJECT]");
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
Assert.assertEquals(project.toString(), actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations