use of com.google.phishingprotection.v1beta1.ProjectName in project gapic-generator-java by googleapis.
the class MetricsClientTest method listLogMetricsExceptionTest.
@Test
public void listLogMetricsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricsServiceV2.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
client.listLogMetrics(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.phishingprotection.v1beta1.ProjectName in project gapic-generator-java by googleapis.
the class MetricsClientTest method listLogMetricsTest.
@Test
public void listLogMetricsTest() throws Exception {
LogMetric responsesElement = LogMetric.newBuilder().build();
ListLogMetricsResponse expectedResponse = ListLogMetricsResponse.newBuilder().setNextPageToken("").addAllMetrics(Arrays.asList(responsesElement)).build();
mockMetricsServiceV2.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListLogMetricsPagedResponse pagedListResponse = client.listLogMetrics(parent);
List<LogMetric> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getMetricsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockMetricsServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListLogMetricsRequest actualRequest = ((ListLogMetricsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.phishingprotection.v1beta1.ProjectName in project gapic-generator-java by googleapis.
the class MetricsClientTest method createLogMetricExceptionTest.
@Test
public void createLogMetricExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricsServiceV2.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
LogMetric metric = LogMetric.newBuilder().build();
client.createLogMetric(parent, metric);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.phishingprotection.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.phishingprotection.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.
}
}
Aggregations