Search in sources :

Example 11 with Service

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

the class ServiceMonitoringServiceClientTest method createServiceTest3.

@Test
public void createServiceTest3() 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);
    ProjectName parent = ProjectName.of("[PROJECT]");
    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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ProjectName(com.google.monitoring.v3.ProjectName) CreateServiceRequest(com.google.monitoring.v3.CreateServiceRequest) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Example 12 with Service

use of com.google.monitoring.v3.Service 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)

Example 13 with Service

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

the class ServiceMonitoringServiceClientTest method getServiceLevelObjectiveTest2.

@Test
public void getServiceLevelObjectiveTest2() 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 name = "name3373707";
    ServiceLevelObjective actualResponse = client.getServiceLevelObjective(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetServiceLevelObjectiveRequest actualRequest = ((GetServiceLevelObjectiveRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    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) GetServiceLevelObjectiveRequest(com.google.monitoring.v3.GetServiceLevelObjectiveRequest) Test(org.junit.Test)

Example 14 with Service

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

the class ServiceMonitoringServiceClientTest method listServiceLevelObjectivesTest.

@Test
public void listServiceLevelObjectivesTest() throws Exception {
    ServiceLevelObjective responsesElement = ServiceLevelObjective.newBuilder().build();
    ListServiceLevelObjectivesResponse expectedResponse = ListServiceLevelObjectivesResponse.newBuilder().setNextPageToken("").addAllServiceLevelObjectives(Arrays.asList(responsesElement)).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
    ListServiceLevelObjectivesPagedResponse pagedListResponse = client.listServiceLevelObjectives(parent);
    List<ServiceLevelObjective> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getServiceLevelObjectivesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListServiceLevelObjectivesRequest actualRequest = ((ListServiceLevelObjectivesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServiceLevelObjectivesRequest(com.google.monitoring.v3.ListServiceLevelObjectivesRequest) ServiceLevelObjective(com.google.monitoring.v3.ServiceLevelObjective) ServiceName(com.google.monitoring.v3.ServiceName) ListServiceLevelObjectivesPagedResponse(com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse) ListServiceLevelObjectivesResponse(com.google.monitoring.v3.ListServiceLevelObjectivesResponse) Test(org.junit.Test)

Example 15 with Service

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

the class ServiceMonitoringServiceClient method deleteServiceLevelObjective.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Delete the given `ServiceLevelObjective`.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient =
 *     ServiceMonitoringServiceClient.create()) {
 *   String name =
 *       ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName(
 *               "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]")
 *           .toString();
 *   serviceMonitoringServiceClient.deleteServiceLevelObjective(name);
 * }
 * }</pre>
 *
 * @param name Required. Resource name of the `ServiceLevelObjective` to delete. The format is:
 *     <p>projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteServiceLevelObjective(String name) {
    DeleteServiceLevelObjectiveRequest request = DeleteServiceLevelObjectiveRequest.newBuilder().setName(name).build();
    deleteServiceLevelObjective(request);
}
Also used : DeleteServiceLevelObjectiveRequest(com.google.monitoring.v3.DeleteServiceLevelObjectiveRequest)

Aggregations

Test (org.junit.jupiter.api.Test)33 Test (org.junit.Test)30 Service (io.fabric8.knative.serving.v1.Service)28 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 AbstractMessage (com.google.protobuf.AbstractMessage)19 CoreException (org.eclipse.core.runtime.CoreException)18 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)16 Service (com.google.monitoring.v3.Service)16 IOException (java.io.IOException)16 HashMap (java.util.HashMap)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 ArrayList (java.util.ArrayList)12 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)11 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)11 StatusRuntimeException (io.grpc.StatusRuntimeException)11 ProdBuildResults (io.quarkus.test.ProdBuildResults)11 ProdModeTestResults (io.quarkus.test.ProdModeTestResults)11 QuarkusProdModeTest (io.quarkus.test.QuarkusProdModeTest)11 Path (java.nio.file.Path)11