use of com.google.monitoring.v3.UptimeCheckConfig 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.
}
}
use of com.google.monitoring.v3.UptimeCheckConfig in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method getUptimeCheckConfigTest2.
@Test
public void getUptimeCheckConfigTest2() 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);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.UptimeCheckConfig in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method createUptimeCheckConfigTest2.
@Test
public void createUptimeCheckConfigTest2() 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);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
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()));
}
use of com.google.monitoring.v3.UptimeCheckConfig in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method listUptimeCheckConfigsTest2.
@Test
public void listUptimeCheckConfigsTest2() throws Exception {
UptimeCheckConfig responsesElement = UptimeCheckConfig.newBuilder().build();
ListUptimeCheckConfigsResponse expectedResponse = ListUptimeCheckConfigsResponse.newBuilder().setNextPageToken("").addAllUptimeCheckConfigs(Arrays.asList(responsesElement)).build();
mockUptimeCheckService.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
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()));
}
use of com.google.monitoring.v3.UptimeCheckConfig in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method createUptimeCheckConfigExceptionTest4.
@Test
public void createUptimeCheckConfigExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockUptimeCheckService.addException(exception);
try {
String parent = "parent-995424086";
UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
client.createUptimeCheckConfig(parent, uptimeCheckConfig);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations