Search in sources :

Example 16 with UptimeCheckConfig

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

the class UptimeCheckServiceClientTest method getUptimeCheckConfigTest.

@Test
public void getUptimeCheckConfigTest() throws Exception {
    UptimeCheckConfig expectedResponse = UptimeCheckConfig.newBuilder().setName(UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]").toString()).setDisplayName("displayName1714148973").setPeriod(Duration.newBuilder().build()).setTimeout(Duration.newBuilder().build()).addAllContentMatchers(new ArrayList<UptimeCheckConfig.ContentMatcher>()).addAllSelectedRegions(new ArrayList<UptimeCheckRegion>()).setIsInternal(true).addAllInternalCheckers(new ArrayList<InternalChecker>()).build();
    mockUptimeCheckService.addResponse(expectedResponse);
    UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockUptimeCheckService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetUptimeCheckConfigRequest actualRequest = ((GetUptimeCheckConfigRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) GetUptimeCheckConfigRequest(com.google.monitoring.v3.GetUptimeCheckConfigRequest) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) UptimeCheckConfigName(com.google.monitoring.v3.UptimeCheckConfigName) Test(org.junit.Test)

Example 17 with UptimeCheckConfig

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

the class UptimeCheckServiceClientTest method updateUptimeCheckConfigTest.

@Test
public void updateUptimeCheckConfigTest() throws Exception {
    UptimeCheckConfig expectedResponse = UptimeCheckConfig.newBuilder().setName(UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]").toString()).setDisplayName("displayName1714148973").setPeriod(Duration.newBuilder().build()).setTimeout(Duration.newBuilder().build()).addAllContentMatchers(new ArrayList<UptimeCheckConfig.ContentMatcher>()).addAllSelectedRegions(new ArrayList<UptimeCheckRegion>()).setIsInternal(true).addAllInternalCheckers(new ArrayList<InternalChecker>()).build();
    mockUptimeCheckService.addResponse(expectedResponse);
    UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    UptimeCheckConfig actualResponse = client.updateUptimeCheckConfig(uptimeCheckConfig);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockUptimeCheckService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateUptimeCheckConfigRequest actualRequest = ((UpdateUptimeCheckConfigRequest) actualRequests.get(0));
    Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) UpdateUptimeCheckConfigRequest(com.google.monitoring.v3.UpdateUptimeCheckConfigRequest) ArrayList(java.util.ArrayList) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) Test(org.junit.Test)

Example 18 with UptimeCheckConfig

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

the class UptimeCheckServiceClientTest method createUptimeCheckConfigExceptionTest3.

@Test
public void createUptimeCheckConfigExceptionTest3() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockUptimeCheckService.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        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) ProjectName(com.google.monitoring.v3.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) Test(org.junit.Test)

Example 19 with UptimeCheckConfig

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

the class UptimeCheckServiceClientTest method listUptimeCheckConfigsTest3.

@Test
public void listUptimeCheckConfigsTest3() throws Exception {
    UptimeCheckConfig responsesElement = UptimeCheckConfig.newBuilder().build();
    ListUptimeCheckConfigsResponse expectedResponse = ListUptimeCheckConfigsResponse.newBuilder().setNextPageToken("").addAllUptimeCheckConfigs(Arrays.asList(responsesElement)).build();
    mockUptimeCheckService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    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) ProjectName(com.google.monitoring.v3.ProjectName) ListUptimeCheckConfigsResponse(com.google.monitoring.v3.ListUptimeCheckConfigsResponse) ListUptimeCheckConfigsPagedResponse(com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) Test(org.junit.Test)

Example 20 with UptimeCheckConfig

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

the class UptimeCheckServiceClientTest method createUptimeCheckConfigTest.

@Test
public void createUptimeCheckConfigTest() throws Exception {
    UptimeCheckConfig expectedResponse = UptimeCheckConfig.newBuilder().setName(UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]").toString()).setDisplayName("displayName1714148973").setPeriod(Duration.newBuilder().build()).setTimeout(Duration.newBuilder().build()).addAllContentMatchers(new ArrayList<UptimeCheckConfig.ContentMatcher>()).addAllSelectedRegions(new ArrayList<UptimeCheckRegion>()).setIsInternal(true).addAllInternalCheckers(new ArrayList<InternalChecker>()).build();
    mockUptimeCheckService.addResponse(expectedResponse);
    FolderName parent = FolderName.of("[FOLDER]");
    UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    UptimeCheckConfig actualResponse = client.createUptimeCheckConfig(parent, uptimeCheckConfig);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockUptimeCheckService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateUptimeCheckConfigRequest actualRequest = ((CreateUptimeCheckConfigRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateUptimeCheckConfigRequest(com.google.monitoring.v3.CreateUptimeCheckConfigRequest) ArrayList(java.util.ArrayList) UptimeCheckConfig(com.google.monitoring.v3.UptimeCheckConfig) FolderName(com.google.monitoring.v3.FolderName) Test(org.junit.Test)

Aggregations

UptimeCheckConfig (com.google.monitoring.v3.UptimeCheckConfig)22 Test (org.junit.Test)16 AbstractMessage (com.google.protobuf.AbstractMessage)11 ArrayList (java.util.ArrayList)7 UptimeCheckServiceClient (com.google.cloud.monitoring.v3.UptimeCheckServiceClient)6 CreateUptimeCheckConfigRequest (com.google.monitoring.v3.CreateUptimeCheckConfigRequest)6 IOException (java.io.IOException)6 ParseException (org.apache.commons.cli.ParseException)6 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)5 StatusRuntimeException (io.grpc.StatusRuntimeException)5 ListUptimeCheckConfigsPagedResponse (com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse)4 ListUptimeCheckConfigsRequest (com.google.monitoring.v3.ListUptimeCheckConfigsRequest)4 ListUptimeCheckConfigsResponse (com.google.monitoring.v3.ListUptimeCheckConfigsResponse)4 FolderName (com.google.monitoring.v3.FolderName)3 OrganizationName (com.google.monitoring.v3.OrganizationName)3 ProjectName (com.google.monitoring.v3.ProjectName)3 UpdateUptimeCheckConfigRequest (com.google.monitoring.v3.UpdateUptimeCheckConfigRequest)3 GetUptimeCheckConfigRequest (com.google.monitoring.v3.GetUptimeCheckConfigRequest)2 UptimeCheckServiceSettings (com.google.cloud.monitoring.v3.UptimeCheckServiceSettings)1 UptimeCheckConfigName (com.google.monitoring.v3.UptimeCheckConfigName)1