Search in sources :

Example 1 with UpdateServiceRequest

use of com.google.monitoring.v3.UpdateServiceRequest in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method updateServiceTest.

@Test
public void updateServiceTest() 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);
    Service service = Service.newBuilder().build();
    Service actualResponse = client.updateService(service);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateServiceRequest actualRequest = ((UpdateServiceRequest) actualRequests.get(0));
    Assert.assertEquals(service, actualRequest.getService());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) UpdateServiceRequest(com.google.monitoring.v3.UpdateServiceRequest) Test(org.junit.Test)

Aggregations

MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)1 Service (com.google.monitoring.v3.Service)1 UpdateServiceRequest (com.google.monitoring.v3.UpdateServiceRequest)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1