Search in sources :

Example 66 with Service

use of com.google.cloud.servicedirectory.v1.Service in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method getServiceTest2.

@Test
public void getServiceTest2() 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);
    String name = "name3373707";
    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, actualRequest.getName());
    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) GetServiceRequest(com.google.monitoring.v3.GetServiceRequest) Test(org.junit.Test)

Example 67 with Service

use of com.google.cloud.servicedirectory.v1.Service in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method createServiceExceptionTest3.

@Test
public void createServiceExceptionTest3() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockServiceMonitoringService.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        Service service = Service.newBuilder().build();
        client.createService(parent, service);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.monitoring.v3.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Example 68 with Service

use of com.google.cloud.servicedirectory.v1.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()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) 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 69 with Service

use of com.google.cloud.servicedirectory.v1.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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) ServiceName(com.google.monitoring.v3.ServiceName) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) GetServiceRequest(com.google.monitoring.v3.GetServiceRequest) Test(org.junit.Test)

Example 70 with Service

use of com.google.cloud.servicedirectory.v1.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.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Service(com.google.monitoring.v3.Service) MockGrpcService(com.google.api.gax.grpc.testing.MockGrpcService) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)33 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 Test (org.junit.Test)19 MockGrpcService (com.google.api.gax.grpc.testing.MockGrpcService)18 CoreException (org.eclipse.core.runtime.CoreException)18 Service (com.google.monitoring.v3.Service)16 IOException (java.io.IOException)15 AbstractMessage (com.google.protobuf.AbstractMessage)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)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 ArrayList (java.util.ArrayList)11 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)11 List (java.util.List)10 DisplayName (org.junit.jupiter.api.DisplayName)10