use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class GroupServiceClientTest method createGroupExceptionTest.
@Test
public void createGroupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
FolderName name = FolderName.of("[FOLDER]");
Group group = Group.newBuilder().build();
client.createGroup(name, group);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.FolderName 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()));
}
use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class UptimeCheckServiceClientTest method listUptimeCheckConfigsExceptionTest.
@Test
public void listUptimeCheckConfigsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockUptimeCheckService.addException(exception);
try {
FolderName parent = FolderName.of("[FOLDER]");
client.listUptimeCheckConfigs(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.FolderName in project java-monitoring by googleapis.
the class MetricServiceClientTest method listTimeSeriesExceptionTest.
@Test
public void listTimeSeriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
FolderName name = FolderName.of("[FOLDER]");
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
client.listTimeSeries(name, filter, interval, view);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.FolderName in project gapic-generator-java by googleapis.
the class SyncCreateSinkFoldernameLogsink method syncCreateSinkFoldernameLogsink.
public static void syncCreateSinkFoldernameLogsink() throws Exception {
// It may require modifications to work in your environment.
try (ConfigClient configClient = ConfigClient.create()) {
FolderName parent = FolderName.of("[FOLDER]");
LogSink sink = LogSink.newBuilder().build();
LogSink response = configClient.createSink(parent, sink);
}
}
Aggregations