Search in sources :

Example 6 with CreateUptimeCheckConfigRequest

use of com.google.monitoring.v3.CreateUptimeCheckConfigRequest 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

CreateUptimeCheckConfigRequest (com.google.monitoring.v3.CreateUptimeCheckConfigRequest)6 UptimeCheckConfig (com.google.monitoring.v3.UptimeCheckConfig)6 AbstractMessage (com.google.protobuf.AbstractMessage)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 UptimeCheckServiceClient (com.google.cloud.monitoring.v3.UptimeCheckServiceClient)2 IOException (java.io.IOException)2 ParseException (org.apache.commons.cli.ParseException)2 FolderName (com.google.monitoring.v3.FolderName)1 OrganizationName (com.google.monitoring.v3.OrganizationName)1 ProjectName (com.google.monitoring.v3.ProjectName)1