use of com.google.monitoring.v3.OrganizationName in project java-monitoring by googleapis.
the class MetricServiceClientTest method createMetricDescriptorExceptionTest2.
@Test
public void createMetricDescriptorExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
client.createMetricDescriptor(name, metricDescriptor);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.OrganizationName in project java-monitoring by googleapis.
the class MetricServiceClientTest method createMetricDescriptorTest2.
@Test
public void createMetricDescriptorTest2() throws Exception {
MetricDescriptor expectedResponse = MetricDescriptor.newBuilder().setName("name3373707").setType("type3575610").addAllLabels(new ArrayList<LabelDescriptor>()).setUnit("unit3594628").setDescription("description-1724546052").setDisplayName("displayName1714148973").setMetadata(MetricDescriptor.MetricDescriptorMetadata.newBuilder().build()).setLaunchStage(LaunchStage.forNumber(0)).addAllMonitoredResourceTypes(new ArrayList<String>()).build();
mockMetricService.addResponse(expectedResponse);
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
MetricDescriptor actualResponse = client.createMetricDescriptor(name, metricDescriptor);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateMetricDescriptorRequest actualRequest = ((CreateMetricDescriptorRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.OrganizationName in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method listAlertPoliciesExceptionTest2.
@Test
public void listAlertPoliciesExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockAlertPolicyService.addException(exception);
try {
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
client.listAlertPolicies(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.OrganizationName in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method createAlertPolicyTest2.
@Test
public void createAlertPolicyTest2() throws Exception {
AlertPolicy expectedResponse = AlertPolicy.newBuilder().setName(AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()).setDisplayName("displayName1714148973").setDocumentation(AlertPolicy.Documentation.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).addAllConditions(new ArrayList<AlertPolicy.Condition>()).setEnabled(BoolValue.newBuilder().build()).setValidity(Status.newBuilder().build()).addAllNotificationChannels(new ArrayList<String>()).setCreationRecord(MutationRecord.newBuilder().build()).setMutationRecord(MutationRecord.newBuilder().build()).setAlertStrategy(AlertPolicy.AlertStrategy.newBuilder().build()).build();
mockAlertPolicyService.addResponse(expectedResponse);
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
AlertPolicy actualResponse = client.createAlertPolicy(name, alertPolicy);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateAlertPolicyRequest actualRequest = ((CreateAlertPolicyRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.OrganizationName in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method createAlertPolicyExceptionTest2.
@Test
public void createAlertPolicyExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockAlertPolicyService.addException(exception);
try {
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
client.createAlertPolicy(name, alertPolicy);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations