Search in sources :

Example 1 with BrokerList

use of io.confluent.kafkarest.entities.v2.BrokerList in project kafka-rest by confluentinc.

the class BrokersResourceTest method testList.

@Test
public void testList() {
    expect(brokerManager.listLocalBrokers()).andReturn(completedFuture(Arrays.asList(BROKER_1, BROKER_2, BROKER_3)));
    replay(brokerManager);
    Response response = request("/brokers", Versions.KAFKA_V2_JSON).get();
    assertOKResponse(response, Versions.KAFKA_V2_JSON);
    final BrokerList returnedBrokerIds = TestUtils.tryReadEntityOrLog(response, new GenericType<BrokerList>() {
    });
    assertEquals(Arrays.asList(1, 2, 3), returnedBrokerIds.getBrokers());
}
Also used : TestUtils.assertOKResponse(io.confluent.kafkarest.TestUtils.assertOKResponse) TestUtils.assertErrorResponse(io.confluent.kafkarest.TestUtils.assertErrorResponse) Response(javax.ws.rs.core.Response) BrokerList(io.confluent.kafkarest.entities.v2.BrokerList) Test(org.junit.jupiter.api.Test)

Example 2 with BrokerList

use of io.confluent.kafkarest.entities.v2.BrokerList in project kafka-rest by confluentinc.

the class MetadataAPITest method testBrokers.

@Test
public void testBrokers() throws InterruptedException {
    // Listing
    Response response = request("/brokers").get();
    assertOKResponse(response, Versions.KAFKA_V2_JSON);
    final BrokerList brokers = tryReadEntityOrLog(response, BrokerList.class);
    assertEquals(new BrokerList(Arrays.asList(0, 1)), brokers);
}
Also used : GetTopicResponse(io.confluent.kafkarest.entities.v2.GetTopicResponse) TestUtils.assertOKResponse(io.confluent.kafkarest.TestUtils.assertOKResponse) Response(javax.ws.rs.core.Response) TestUtils.assertErrorResponse(io.confluent.kafkarest.TestUtils.assertErrorResponse) GetPartitionResponse(io.confluent.kafkarest.entities.v2.GetPartitionResponse) BrokerList(io.confluent.kafkarest.entities.v2.BrokerList) Test(org.junit.jupiter.api.Test)

Example 3 with BrokerList

use of io.confluent.kafkarest.entities.v2.BrokerList in project kafka-rest by confluentinc.

the class BrokersResource method list.

@GET
@PerformanceMetric("brokers.list+v2")
@ResourceName("api.v2.brokers.list")
public void list(@Suspended AsyncResponse asyncResponse) {
    CompletableFuture<BrokerList> response = brokerManager.get().listLocalBrokers().thenApply(brokers -> new BrokerList(brokers.stream().map(Broker::getBrokerId).collect(Collectors.toList())));
    AsyncResponses.asyncResume(asyncResponse, response);
}
Also used : BrokerList(io.confluent.kafkarest.entities.v2.BrokerList) PerformanceMetric(io.confluent.rest.annotations.PerformanceMetric) ResourceName(io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName) GET(javax.ws.rs.GET)

Aggregations

BrokerList (io.confluent.kafkarest.entities.v2.BrokerList)3 TestUtils.assertErrorResponse (io.confluent.kafkarest.TestUtils.assertErrorResponse)2 TestUtils.assertOKResponse (io.confluent.kafkarest.TestUtils.assertOKResponse)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.jupiter.api.Test)2 GetPartitionResponse (io.confluent.kafkarest.entities.v2.GetPartitionResponse)1 GetTopicResponse (io.confluent.kafkarest.entities.v2.GetTopicResponse)1 ResourceName (io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName)1 PerformanceMetric (io.confluent.rest.annotations.PerformanceMetric)1 GET (javax.ws.rs.GET)1