Search in sources :

Example 1 with KubernetesCrudDispatcher

use of io.fabric8.kubernetes.client.server.mock.KubernetesCrudDispatcher in project kubernetes-client by fabric8io.

the class CustomResourceCrud1109Test method test1109GetList.

@Test
@DisplayName("Get CR list, with CR created through KubernetesCrudDispatcher, should perform GET to crd list with dashed plural")
void test1109GetList() {
    // Given
    final FooBar fb1 = new FooBar();
    fb1.getMetadata().setName("example");
    fooBarClient.inNamespace("default").create(fb1);
    // When
    final KubernetesResourceList<FooBar> fooBarList = fooBarClient.inNamespace("default").list();
    // Then
    assertThat(fooBarList).isNotNull().extracting(KubernetesResourceList::getItems).asList().hasSize(1);
}
Also used : KubernetesResourceList(io.fabric8.kubernetes.api.model.KubernetesResourceList) FooBar(io.fabric8.kubernetes.client.mock.crd.FooBar) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with KubernetesCrudDispatcher

use of io.fabric8.kubernetes.client.server.mock.KubernetesCrudDispatcher in project kubernetes-client by fabric8io.

the class CustomResourceCrud1109Test method test1109GetSingleResource.

@Test
@DisplayName("Get single CR resource, with CR created through KubernetesCrudDispatcher, should perform GET to crd list with dashed plural")
void test1109GetSingleResource() {
    // Given
    final FooBar fb1 = new FooBar();
    fb1.getMetadata().setName("example");
    fooBarClient.inNamespace("default").create(fb1);
    // When
    final FooBar fooBar = fooBarClient.inNamespace("default").withName("example").get();
    // Then
    assertThat(fooBar).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "example").hasFieldOrPropertyWithValue("kind", "FooBar").isNotSameAs(fb1);
}
Also used : FooBar(io.fabric8.kubernetes.client.mock.crd.FooBar) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with KubernetesCrudDispatcher

use of io.fabric8.kubernetes.client.server.mock.KubernetesCrudDispatcher in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class IngressControllerManagerTest method cleanup.

@BeforeEach
@AfterEach
void cleanup() {
    // clears the mock server state
    // won't be needed after quarkus fixes issues with WithKubernetesTestServer
    kubernetesServer.getMockServer().setDispatcher(new KubernetesCrudDispatcher());
    ingressControllerManager.getRouteMatchLabels().clear();
}
Also used : KubernetesCrudDispatcher(io.fabric8.kubernetes.client.server.mock.KubernetesCrudDispatcher) BeforeEach(org.junit.jupiter.api.BeforeEach) AfterEach(org.junit.jupiter.api.AfterEach)

Aggregations

FooBar (io.fabric8.kubernetes.client.mock.crd.FooBar)2 DisplayName (org.junit.jupiter.api.DisplayName)2 Test (org.junit.jupiter.api.Test)2 KubernetesResourceList (io.fabric8.kubernetes.api.model.KubernetesResourceList)1 KubernetesCrudDispatcher (io.fabric8.kubernetes.client.server.mock.KubernetesCrudDispatcher)1 AfterEach (org.junit.jupiter.api.AfterEach)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1