Search in sources :

Example 1 with CreateServiceLevelObjectiveRequest

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

the class ServiceMonitoringServiceClientTest method createServiceLevelObjectiveTest.

@Test
public void createServiceLevelObjectiveTest() throws Exception {
    ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder().setName(ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]").toString()).setDisplayName("displayName1714148973").setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()).setGoal(3178259).putAllUserLabels(new HashMap<String, String>()).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
    ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
    ServiceLevelObjective actualResponse = client.createServiceLevelObjective(parent, serviceLevelObjective);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateServiceLevelObjectiveRequest actualRequest = ((CreateServiceLevelObjectiveRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(serviceLevelObjective, actualRequest.getServiceLevelObjective());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ServiceLevelObjective(com.google.monitoring.v3.ServiceLevelObjective) HashMap(java.util.HashMap) ServiceName(com.google.monitoring.v3.ServiceName) CreateServiceLevelObjectiveRequest(com.google.monitoring.v3.CreateServiceLevelObjectiveRequest) Test(org.junit.Test)

Example 2 with CreateServiceLevelObjectiveRequest

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

the class ServiceMonitoringServiceClientTest method createServiceLevelObjectiveTest2.

@Test
public void createServiceLevelObjectiveTest2() throws Exception {
    ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder().setName(ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]").toString()).setDisplayName("displayName1714148973").setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()).setGoal(3178259).putAllUserLabels(new HashMap<String, String>()).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
    ServiceLevelObjective actualResponse = client.createServiceLevelObjective(parent, serviceLevelObjective);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateServiceLevelObjectiveRequest actualRequest = ((CreateServiceLevelObjectiveRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(serviceLevelObjective, actualRequest.getServiceLevelObjective());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ServiceLevelObjective(com.google.monitoring.v3.ServiceLevelObjective) HashMap(java.util.HashMap) CreateServiceLevelObjectiveRequest(com.google.monitoring.v3.CreateServiceLevelObjectiveRequest) Test(org.junit.Test)

Aggregations

CreateServiceLevelObjectiveRequest (com.google.monitoring.v3.CreateServiceLevelObjectiveRequest)2 ServiceLevelObjective (com.google.monitoring.v3.ServiceLevelObjective)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 ServiceName (com.google.monitoring.v3.ServiceName)1