use of com.google.monitoring.v3.OrganizationName in project java-monitoring by googleapis.
the class GroupServiceClientTest method listGroupsTest2.
@Test
public void listGroupsTest2() throws Exception {
Group responsesElement = Group.newBuilder().build();
ListGroupsResponse expectedResponse = ListGroupsResponse.newBuilder().setNextPageToken("").addAllGroup(Arrays.asList(responsesElement)).build();
mockGroupService.addResponse(expectedResponse);
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
ListGroupsPagedResponse pagedListResponse = client.listGroups(name);
List<Group> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getGroupList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListGroupsRequest actualRequest = ((ListGroupsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java by googleapis.
the class SyncCreateExclusionOrganizationnameLogexclusion method syncCreateExclusionOrganizationnameLogexclusion.
public static void syncCreateExclusionOrganizationnameLogexclusion() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
LogExclusion exclusion = LogExclusion.newBuilder().build();
LogExclusion response = configClient.createExclusion(parent, exclusion);
}
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java by googleapis.
the class SyncCreateSinkOrganizationnameLogsink method syncCreateSinkOrganizationnameLogsink.
public static void syncCreateSinkOrganizationnameLogsink() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
LogSink sink = LogSink.newBuilder().build();
LogSink response = configClient.createSink(parent, sink);
}
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java by googleapis.
the class ConfigClientTest method listSinksExceptionTest3.
@Test
public void listSinksExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
client.listSinks(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java by googleapis.
the class LoggingClientTest method listLogsExceptionTest3.
@Test
public void listLogsExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLoggingServiceV2.addException(exception);
try {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
client.listLogs(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations