use of com.google.storage.v2.ProjectName in project gapic-generator-java by googleapis.
the class ConfigClientTest method listSinksExceptionTest4.
@Test
public void listSinksExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
client.listSinks(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.storage.v2.ProjectName in project gapic-generator-java by googleapis.
the class ConfigClientTest method listExclusionsTest4.
@Test
public void listExclusionsTest4() throws Exception {
LogExclusion responsesElement = LogExclusion.newBuilder().build();
ListExclusionsResponse expectedResponse = ListExclusionsResponse.newBuilder().setNextPageToken("").addAllExclusions(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListExclusionsPagedResponse pagedListResponse = client.listExclusions(parent);
List<LogExclusion> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getExclusionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListExclusionsRequest actualRequest = ((ListExclusionsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.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.storage.v2.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.storage.v2.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.
}
}
Aggregations