use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project kubernetes-client by fabric8io.
the class ServiceCrudTest method shouldListAndGetService.
@Test
void shouldListAndGetService() {
Service service2 = new ServiceBuilder().withNewMetadata().withName("service2").endMetadata().build();
client.services().inNamespace("ns2").create(service2);
ServiceList serviceList = client.services().inNamespace("ns2").list();
assertNotNull(serviceList);
assertEquals(1, serviceList.getItems().size());
Service service = client.services().inNamespace("ns2").withName("service2").get();
assertNotNull(service);
assertEquals("service2", service.getMetadata().getName());
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Service in project kubernetes-client by fabric8io.
the class ServiceCrudTest method shouldIncludeServiceStatus.
@Test
void shouldIncludeServiceStatus() {
Service service = new ServiceBuilder().withNewMetadata().withName("service").endMetadata().build();
Service created = client.services().inNamespace("ns2").create(service);
ServiceList serviceList = client.services().inNamespace("ns2").list();
assertNotNull(serviceList);
assertEquals(1, serviceList.getItems().size());
created.setStatus(new ServiceStatusBuilder().withNewAddress("http://my-service").build());
assertNotNull(client.services().inNamespace("ns2").withName("service").updateStatus(created).getStatus());
}
use of com.marcnuri.yakc.model.io.k8s.api.core.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()));
}
use of com.marcnuri.yakc.model.io.k8s.api.core.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.
}
}
use of com.marcnuri.yakc.model.io.k8s.api.core.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()));
}
Aggregations