### Question:
KafkaResource { @GET @Path("/clusters") @Produces(MediaType.APPLICATION_JSON) public List<KafkaCluster> listKafkaClusters() { return kafkaService.listClusters(); } @Inject  KafkaResource(KafkaService kafkaService); @GET @Path("/clusters") @Produces(MediaType.APPLICATION_JSON) List<KafkaCluster> listKafkaClusters(); @POST @Path("/clusters") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) KafkaCluster addKafkaCluster(KafkaCluster kafkaCluster); @GET @Path("/clusters/{clusterId}") @Produces(MediaType.APPLICATION_JSON) KafkaCluster getKafkaCluster(@PathParam("clusterId") String clusterId); @DELETE @Path("/clusters/{clusterId}") Response removeKafkaCluster(@PathParam("clusterId") String clusterId); @GET @Path("/clusters/{clusterId}/topics") @Produces(MediaType.APPLICATION_JSON) List<KafkaTopic> listKafkaTopics(@PathParam("clusterId") String clusterId); @POST @Path("/clusters/{clusterId}/topics") Response addKafkaTopic(@PathParam("clusterId") String clusterId, KafkaTopic topic); @DELETE @Path("/clusters/{clusterId}/topics/{topicName}") Response deleteKafkaTopic(@PathParam("clusterId") String clusterId, 
            @PathParam("topicName") String topicName);  }### Answer:
@Test public void listKafkaClusters() { KafkaCluster cluster1 = new KafkaCluster(); cluster1.setId("kafkaCluster-1"); cluster1.setName("Kafka Cluster 1"); cluster1.setZookeeperUri("zookeeper: KafkaCluster cluster2 = new KafkaCluster(); cluster2.setId("kafkaCluster-2"); cluster2.setName("Kafka Cluster 2"); cluster2.setZookeeperUri("zookeeper: List<KafkaCluster> mockedClusters = new ArrayList<KafkaCluster>(); mockedClusters.add(cluster1); mockedClusters.add(cluster2); when(kafkaServiceMock.listClusters()).thenReturn(mockedClusters); List<KafkaCluster> responseClusters = resource().path("/api/kafka/clusters") .accept(MediaType.APPLICATION_JSON).get(new GenericType<List<KafkaCluster>>(){}); assertEquals("Response kafka clusters should be equal to the mocked kafka clusters", mockedClusters, responseClusters); verify(kafkaServiceMock).listClusters(); }