use of io.strimzi.api.kafka.KafkaTopicList in project strimzi by strimzi.
the class K8sImplTest method testList.
@Test
public void testList(VertxTestContext context) {
Checkpoint async = context.checkpoint();
List<KafkaTopic> mockKafkaTopicsList = Collections.singletonList(new KafkaTopicBuilder().withMetadata(new ObjectMetaBuilder().withName("unrelated").withLabels(Collections.singletonMap("foo", "bar")).build()).build());
KubernetesClient mockClient = mock(KubernetesClient.class);
MixedOperation<KafkaTopic, KafkaTopicList, Resource<KafkaTopic>> mockResources = mock(MixedOperation.class);
when(mockClient.resources(any(Class.class), any(Class.class))).thenReturn(mockResources);
when(mockClient.resources(any(Class.class), any(Class.class))).thenReturn(mockResources);
when(mockResources.withLabels(any())).thenReturn(mockResources);
when(mockResources.inNamespace(any())).thenReturn(mockResources);
when(mockResources.list()).thenAnswer(invocation -> {
KafkaTopicList ktl = new KafkaTopicList();
ktl.setItems(mockKafkaTopicsList);
return ktl;
});
K8sImpl k8s = new K8sImpl(vertx, mockClient, new Labels("foo", "bar"), "default");
k8s.listResources().onComplete(context.succeeding(kafkaTopics -> context.verify(() -> {
assertThat(kafkaTopics, is(mockKafkaTopicsList));
async.flag();
})));
}
use of io.strimzi.api.kafka.KafkaTopicList in project strimzi-kafka-operator by strimzi.
the class K8sImplTest method testList.
@Test
public void testList(VertxTestContext context) {
Checkpoint async = context.checkpoint();
List<KafkaTopic> mockKafkaTopicsList = Collections.singletonList(new KafkaTopicBuilder().withMetadata(new ObjectMetaBuilder().withName("unrelated").withLabels(Collections.singletonMap("foo", "bar")).build()).build());
KubernetesClient mockClient = mock(KubernetesClient.class);
MixedOperation<KafkaTopic, KafkaTopicList, Resource<KafkaTopic>> mockResources = mock(MixedOperation.class);
when(mockClient.resources(any(Class.class), any(Class.class))).thenReturn(mockResources);
when(mockClient.resources(any(Class.class), any(Class.class))).thenReturn(mockResources);
when(mockResources.withLabels(any())).thenReturn(mockResources);
when(mockResources.inNamespace(any())).thenReturn(mockResources);
when(mockResources.list()).thenAnswer(invocation -> {
KafkaTopicList ktl = new KafkaTopicList();
ktl.setItems(mockKafkaTopicsList);
return ktl;
});
K8sImpl k8s = new K8sImpl(vertx, mockClient, new Labels("foo", "bar"), "default");
k8s.listResources().onComplete(context.succeeding(kafkaTopics -> context.verify(() -> {
assertThat(kafkaTopics, is(mockKafkaTopicsList));
async.flag();
})));
}
Aggregations