Search in sources :

Example 56 with OrganizationName

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()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) ListGroupsPagedResponse(com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse) ListGroupsRequest(com.google.monitoring.v3.ListGroupsRequest) Group(com.google.monitoring.v3.Group) AbstractMessage(com.google.protobuf.AbstractMessage) ListGroupsResponse(com.google.monitoring.v3.ListGroupsResponse) Test(org.junit.Test)

Example 57 with OrganizationName

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);
    }
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) ConfigClient(com.google.cloud.logging.v2.ConfigClient) LogExclusion(com.google.logging.v2.LogExclusion)

Example 58 with OrganizationName

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);
    }
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) LogSink(com.google.logging.v2.LogSink) ConfigClient(com.google.cloud.logging.v2.ConfigClient)

Example 59 with OrganizationName

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.
    }
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 60 with OrganizationName

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.
    }
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)62 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)31 AbstractMessage (com.google.protobuf.AbstractMessage)31 StatusRuntimeException (io.grpc.StatusRuntimeException)31 OrganizationName (com.google.monitoring.v3.OrganizationName)30 OrganizationName (com.google.logging.v2.OrganizationName)22 OrganizationName (com.google.privacy.dlp.v2.OrganizationName)12 LogExclusion (com.google.logging.v2.LogExclusion)7 LogSink (com.google.logging.v2.LogSink)7 ArrayList (java.util.ArrayList)7 MetricDescriptor (com.google.api.MetricDescriptor)3 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)3 AlertPolicy (com.google.monitoring.v3.AlertPolicy)3 UptimeCheckConfig (com.google.monitoring.v3.UptimeCheckConfig)3 InspectTemplate (com.google.privacy.dlp.v2.InspectTemplate)3 ConfigClient (com.google.cloud.logging.v2.ConfigClient)2 ListExclusionsPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListExclusionsPagedResponse)2 ListSinksPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse)2 ListLogsPagedResponse (com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse)2 CreateExclusionRequest (com.google.logging.v2.CreateExclusionRequest)2