use of com.marcnuri.yakc.model.io.k8s.api.core.v1.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()));
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.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()));
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method updateServiceExceptionTest.
@Test
public void updateServiceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockServiceMonitoringService.addException(exception);
try {
Service service = Service.newBuilder().build();
client.updateService(service);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project java-monitoring by googleapis.
the class ServiceMonitoringServiceClientTest method createServiceTest4.
@Test
public void createServiceTest4() 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 parent = "parent-995424086";
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, actualRequest.getParent());
Assert.assertEquals(service, actualRequest.getService());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project kubernetes-client by fabric8io.
the class ResourceTest method resourceInNamespaceCreate.
// https://github.com/quarkusio/quarkus/issues/19950
@Test
@DisplayName("resource, with Knative model in namespace, can createOrReplace")
void resourceInNamespaceCreate() {
// Given
final Service service = new ServiceBuilder().withNewMetadata().withName("service-resource").endMetadata().build();
// When
final HasMetadata hm = client.resource(service).inNamespace("default").createOrReplace();
// Then
assertNotNull(hm);
}
Aggregations