use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceTest2.
@Test
public void createServiceTest2() throws Exception {
Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
mockServiceMonitoringService.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
Service service = Service.newBuilder().build();
Service actualResponse = client.createService(parent, service);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(service, actualRequest.getService());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method getServiceTest.
@Test
public void getServiceTest() throws Exception {
Service expectedResponse = Service.newBuilder().setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()).setDisplayName("displayName1714148973").setTelemetry(Service.Telemetry.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).build();
mockServiceMonitoringService.addResponse(expectedResponse);
ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
Service actualResponse = client.getService(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetServiceRequest actualRequest = ((GetServiceRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method deleteServiceTest.
@Test
public void deleteServiceTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockServiceMonitoringService.addResponse(expectedResponse);
ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
client.deleteService(name);
List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteServiceRequest actualRequest = ((DeleteServiceRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method listServiceLevelObjectivesExceptionTest.
@Test
public void listServiceLevelObjectivesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
client.listServiceLevelObjectives(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceExceptionTest4.
@Test
public void createServiceExceptionTest4() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
String parent = "parent-995424086";
Service service = Service.newBuilder().build();
client.createService(parent, service);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations