Search in sources :

Example 1 with ConfigMapListBuilder

use of io.fabric8.kubernetes.api.model.ConfigMapListBuilder in project strimzi by strimzi.

the class K8sImplTest method testList.

@Test
public void testList(TestContext context) {
    Async async = context.async();
    KubernetesClient mockClient = mock(KubernetesClient.class);
    MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mockConfigMaps = mock(MixedOperation.class);
    when(mockClient.configMaps()).thenReturn(mockConfigMaps);
    when(mockConfigMaps.withLabels(any())).thenReturn(mockConfigMaps);
    when(mockConfigMaps.inNamespace(any())).thenReturn(mockConfigMaps);
    when(mockConfigMaps.list()).thenReturn(new ConfigMapListBuilder().addNewItem().withKind("ConfigMap").withNewMetadata().withName("unrelated").withLabels(Collections.singletonMap("foo", "bar")).endMetadata().withData(Collections.singletonMap("foo", "bar")).endItem().addNewItem().endItem().build());
    K8sImpl k8s = new K8sImpl(vertx, mockClient, new LabelPredicate("foo", "bar"), "default");
    k8s.listMaps(ar -> {
        List<ConfigMap> list = ar.result();
        context.assertFalse(list.isEmpty());
        async.complete();
    });
}
Also used : ConfigMapList(io.fabric8.kubernetes.api.model.ConfigMapList) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Async(io.vertx.ext.unit.Async) Resource(io.fabric8.kubernetes.client.dsl.Resource) ConfigMapListBuilder(io.fabric8.kubernetes.api.model.ConfigMapListBuilder) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) Test(org.junit.Test)

Aggregations

ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)1 ConfigMapList (io.fabric8.kubernetes.api.model.ConfigMapList)1 ConfigMapListBuilder (io.fabric8.kubernetes.api.model.ConfigMapListBuilder)1 DoneableConfigMap (io.fabric8.kubernetes.api.model.DoneableConfigMap)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 Async (io.vertx.ext.unit.Async)1 Test (org.junit.Test)1