use of com.google.monitoring.v3.FolderName in project java-logging by googleapis.
the class ConfigClientTest method createSinkExceptionTest2.
@Test
public void createSinkExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
FolderName parent = FolderName.of("[FOLDER]");
LogSink sink = LogSink.newBuilder().build();
client.createSink(parent, sink);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.FolderName in project java-logging by googleapis.
the class LoggingClientTest method listLogsExceptionTest2.
@Test
public void listLogsExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLoggingServiceV2.addException(exception);
try {
FolderName parent = FolderName.of("[FOLDER]");
client.listLogs(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.FolderName in project java-logging by googleapis.
the class ConfigClientTest method listSinksTest2.
@Test
public void listSinksTest2() throws Exception {
LogSink responsesElement = LogSink.newBuilder().build();
ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken("").addAllSinks(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
FolderName parent = FolderName.of("[FOLDER]");
ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSinksRequest actualRequest = ((ListSinksRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.FolderName in project java-logging by googleapis.
the class ConfigClientTest method listExclusionsTest2.
@Test
public void listExclusionsTest2() throws Exception {
LogExclusion responsesElement = LogExclusion.newBuilder().build();
ListExclusionsResponse expectedResponse = ListExclusionsResponse.newBuilder().setNextPageToken("").addAllExclusions(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
FolderName parent = FolderName.of("[FOLDER]");
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.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class GroupServiceClientTest method listGroupsExceptionTest.
@Test
public void listGroupsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
FolderName name = FolderName.of("[FOLDER]");
client.listGroups(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations