Search in sources :

Example 1 with CronJobListBuilder

use of io.fabric8.kubernetes.api.model.batch.v1.CronJobListBuilder in project kubernetes-client by fabric8io.

the class CronJobTest method testList.

@Test
void testList() {
    server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs").andReturn(200, new CronJobListBuilder().build()).once();
    server.expect().withPath("/apis/batch/v1beta1/namespaces/ns1/cronjobs").andReturn(200, new CronJobListBuilder().addNewItem().and().addNewItem().and().build()).once();
    server.expect().withPath("/apis/batch/v1beta1/cronjobs").andReturn(200, new CronJobListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once();
    CronJobList cronJobList = client.batch().cronjobs().list();
    assertNotNull(cronJobList);
    assertEquals(0, cronJobList.getItems().size());
    cronJobList = client.batch().cronjobs().inNamespace("ns1").list();
    assertNotNull(cronJobList);
    assertEquals(2, cronJobList.getItems().size());
    cronJobList = client.batch().cronjobs().inAnyNamespace().list();
    assertNotNull(cronJobList);
    assertEquals(3, cronJobList.getItems().size());
}
Also used : CronJobListBuilder(io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobListBuilder) CronJobList(io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobList) Test(org.junit.jupiter.api.Test)

Example 2 with CronJobListBuilder

use of io.fabric8.kubernetes.api.model.batch.v1.CronJobListBuilder in project kubernetes-client by fabric8io.

the class V1CronJobTest method testListWithLables.

@Test
void testListWithLables() {
    server.expect().withPath("/apis/batch/v1/namespaces/test/cronjobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new CronJobListBuilder().build()).always();
    server.expect().withPath("/apis/batch/v1/namespaces/test/cronjobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new CronJobListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once();
    CronJobList cronJobList = client.batch().v1().cronjobs().withLabel("key1", "value1").withLabel("key2", "value2").withLabel("key3", "value3").list();
    assertNotNull(cronJobList);
    assertEquals(0, cronJobList.getItems().size());
    cronJobList = client.batch().v1().cronjobs().withLabel("key1", "value1").withLabel("key2", "value2").list();
    assertNotNull(cronJobList);
    assertEquals(3, cronJobList.getItems().size());
}
Also used : CronJobListBuilder(io.fabric8.kubernetes.api.model.batch.v1.CronJobListBuilder) CronJobList(io.fabric8.kubernetes.api.model.batch.v1.CronJobList) Test(org.junit.jupiter.api.Test)

Example 3 with CronJobListBuilder

use of io.fabric8.kubernetes.api.model.batch.v1.CronJobListBuilder in project kubernetes-client by fabric8io.

the class V1CronJobTest method testList.

@Test
void testList() {
    server.expect().withPath("/apis/batch/v1/namespaces/test/cronjobs").andReturn(200, new CronJobListBuilder().build()).once();
    server.expect().withPath("/apis/batch/v1/namespaces/ns1/cronjobs").andReturn(200, new CronJobListBuilder().addNewItem().and().addNewItem().and().build()).once();
    server.expect().withPath("/apis/batch/v1/cronjobs").andReturn(200, new CronJobListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once();
    CronJobList cronJobList = client.batch().v1().cronjobs().list();
    assertNotNull(cronJobList);
    assertEquals(0, cronJobList.getItems().size());
    cronJobList = client.batch().v1().cronjobs().inNamespace("ns1").list();
    assertNotNull(cronJobList);
    assertEquals(2, cronJobList.getItems().size());
    cronJobList = client.batch().v1().cronjobs().inAnyNamespace().list();
    assertNotNull(cronJobList);
    assertEquals(3, cronJobList.getItems().size());
}
Also used : CronJobListBuilder(io.fabric8.kubernetes.api.model.batch.v1.CronJobListBuilder) CronJobList(io.fabric8.kubernetes.api.model.batch.v1.CronJobList) Test(org.junit.jupiter.api.Test)

Example 4 with CronJobListBuilder

use of io.fabric8.kubernetes.api.model.batch.v1.CronJobListBuilder in project kubernetes-client by fabric8io.

the class CronJobTest method testListWithLables.

@Test
void testListWithLables() {
    server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new CronJobListBuilder().build()).always();
    server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new CronJobListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once();
    CronJobList cronJobList = client.batch().cronjobs().withLabel("key1", "value1").withLabel("key2", "value2").withLabel("key3", "value3").list();
    assertNotNull(cronJobList);
    assertEquals(0, cronJobList.getItems().size());
    cronJobList = client.batch().cronjobs().withLabel("key1", "value1").withLabel("key2", "value2").list();
    assertNotNull(cronJobList);
    assertEquals(3, cronJobList.getItems().size());
}
Also used : CronJobListBuilder(io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobListBuilder) CronJobList(io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobList) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 CronJobList (io.fabric8.kubernetes.api.model.batch.v1.CronJobList)2 CronJobListBuilder (io.fabric8.kubernetes.api.model.batch.v1.CronJobListBuilder)2 CronJobList (io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobList)2 CronJobListBuilder (io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobListBuilder)2