Search in sources :

Example 11 with FolderName

use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.

the class MetricServiceClientTest method listMonitoredResourceDescriptorsExceptionTest.

@Test
public void listMonitoredResourceDescriptorsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockMetricService.addException(exception);
    try {
        FolderName name = FolderName.of("[FOLDER]");
        client.listMonitoredResourceDescriptors(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) FolderName(com.google.monitoring.v3.FolderName) Test(org.junit.Test)

Example 12 with FolderName

use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.

the class AlertPolicyServiceClientTest method listAlertPoliciesExceptionTest.

@Test
public void listAlertPoliciesExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockAlertPolicyService.addException(exception);
    try {
        FolderName name = FolderName.of("[FOLDER]");
        client.listAlertPolicies(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) FolderName(com.google.monitoring.v3.FolderName) Test(org.junit.Test)

Example 13 with FolderName

use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.

the class UptimeCheckServiceClientTest method createUptimeCheckConfigExceptionTest.

@Test
public void createUptimeCheckConfigExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockUptimeCheckService.addException(exception);
    try {
        FolderName parent = FolderName.of("[FOLDER]");
        UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
        client.createUptimeCheckConfig(parent, uptimeCheckConfig);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) FolderName(com.google.monitoring.v3.FolderName) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) Test(org.junit.Test)

Example 14 with FolderName

use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.

the class UptimeCheckServiceClientTest method listUptimeCheckConfigsTest.

@Test
public void listUptimeCheckConfigsTest() throws Exception {
    UptimeCheckConfig responsesElement = UptimeCheckConfig.newBuilder().build();
    ListUptimeCheckConfigsResponse expectedResponse = ListUptimeCheckConfigsResponse.newBuilder().setNextPageToken("").addAllUptimeCheckConfigs(Arrays.asList(responsesElement)).build();
    mockUptimeCheckService.addResponse(expectedResponse);
    FolderName parent = FolderName.of("[FOLDER]");
    ListUptimeCheckConfigsPagedResponse pagedListResponse = client.listUptimeCheckConfigs(parent);
    List<UptimeCheckConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getUptimeCheckConfigsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockUptimeCheckService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListUptimeCheckConfigsRequest actualRequest = ((ListUptimeCheckConfigsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListUptimeCheckConfigsRequest(com.google.monitoring.v3.ListUptimeCheckConfigsRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ListUptimeCheckConfigsResponse(com.google.monitoring.v3.ListUptimeCheckConfigsResponse) ListUptimeCheckConfigsPagedResponse(com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) FolderName(com.google.monitoring.v3.FolderName) Test(org.junit.Test)

Example 15 with FolderName

use of com.google.monitoring.v3.FolderName in project gapic-generator-java by googleapis.

the class ConfigClientTest method createSinkTest2.

@Test
public void createSinkTest2() throws Exception {
    LogSink expectedResponse = LogSink.newBuilder().setName(LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]").toString()).setDestination("destination-1429847026").setFilter("filter-1274492040").setDescription("description-1724546052").setDisabled(true).addAllExclusions(new ArrayList<LogExclusion>()).setWriterIdentity("writerIdentity925193809").setIncludeChildren(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    FolderName parent = FolderName.of("[FOLDER]");
    LogSink sink = LogSink.newBuilder().build();
    LogSink actualResponse = client.createSink(parent, sink);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSinkRequest actualRequest = ((CreateSinkRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(sink, actualRequest.getSink());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) CreateSinkRequest(com.google.logging.v2.CreateSinkRequest) FolderName(com.google.logging.v2.FolderName) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)50 FolderName (com.google.monitoring.v3.FolderName)30 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)25 AbstractMessage (com.google.protobuf.AbstractMessage)25 StatusRuntimeException (io.grpc.StatusRuntimeException)25 FolderName (com.google.logging.v2.FolderName)22 LogExclusion (com.google.logging.v2.LogExclusion)7 LogSink (com.google.logging.v2.LogSink)7 ArrayList (java.util.ArrayList)6 MetricDescriptor (com.google.api.MetricDescriptor)3 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)3 AlertPolicy (com.google.monitoring.v3.AlertPolicy)3 Group (com.google.monitoring.v3.Group)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 CreateSinkRequest (com.google.logging.v2.CreateSinkRequest)2 ListExclusionsRequest (com.google.logging.v2.ListExclusionsRequest)2