use of com.google.cloud.datalabeling.v1beta1.ProjectName in project gapic-generator-java by googleapis.
the class MetricsClientTest method createLogMetricTest.
@Test
public void createLogMetricTest() throws Exception {
LogMetric expectedResponse = LogMetric.newBuilder().setName(LogMetricName.of("[PROJECT]", "[METRIC]").toString()).setDescription("description-1724546052").setFilter("filter-1274492040").setMetricDescriptor(MetricDescriptor.newBuilder().build()).setValueExtractor("valueExtractor-1867420749").putAllLabelExtractors(new HashMap<String, String>()).setBucketOptions(Distribution.BucketOptions.newBuilder().build()).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
mockMetricsServiceV2.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
LogMetric metric = LogMetric.newBuilder().build();
LogMetric actualResponse = client.createLogMetric(parent, metric);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockMetricsServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateLogMetricRequest actualRequest = ((CreateLogMetricRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(metric, actualRequest.getMetric());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project gapic-generator-java by googleapis.
the class ConfigClientTest method createSinkExceptionTest4.
@Test
public void createSinkExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
LogSink sink = LogSink.newBuilder().build();
client.createSink(parent, sink);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.datalabeling.v1beta1.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.datalabeling.v1beta1.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.datalabeling.v1beta1.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);
}
}
Aggregations