@Test public void listTopicConfigs_nonExistingTopicOrCluster_throwsNotFound() { expect(topicConfigManager.listTopicConfigs(CLUSTER_ID, TOPIC_NAME)) .andReturn(failedFuture(new NotFoundException())); replay(topicConfigManager); FakeAsyncResponse response = new FakeAsyncResponse(); topicConfigsResource.listTopicConfigs(response, CLUSTER_ID, TOPIC_NAME); assertEquals(NotFoundException.class, response.getException().getClass()); }
@GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.list") public void listTopicConfigs( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName ) { CompletableFuture<ListTopicConfigsResponse> response = topicConfigManager.get() .listTopicConfigs(clusterId, topicName) .thenApply( configs -> ListTopicConfigsResponse.create( TopicConfigDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "configs")) .build()) .setData( configs.stream() .sorted(Comparator.comparing(TopicConfig::getName)) .map(this::toTopicConfigData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); }
TopicConfigsResource { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.list") public void listTopicConfigs( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName ) { CompletableFuture<ListTopicConfigsResponse> response = topicConfigManager.get() .listTopicConfigs(clusterId, topicName) .thenApply( configs -> ListTopicConfigsResponse.create( TopicConfigDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "configs")) .build()) .setData( configs.stream() .sorted(Comparator.comparing(TopicConfig::getName)) .map(this::toTopicConfigData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } }
TopicConfigsResource { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.list") public void listTopicConfigs( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName ) { CompletableFuture<ListTopicConfigsResponse> response = topicConfigManager.get() .listTopicConfigs(clusterId, topicName) .thenApply( configs -> ListTopicConfigsResponse.create( TopicConfigDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "configs")) .build()) .setData( configs.stream() .sorted(Comparator.comparing(TopicConfig::getName)) .map(this::toTopicConfigData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  TopicConfigsResource(
      Provider<TopicConfigManager> topicConfigManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); }
TopicConfigsResource { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.list") public void listTopicConfigs( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName ) { CompletableFuture<ListTopicConfigsResponse> response = topicConfigManager.get() .listTopicConfigs(clusterId, topicName) .thenApply( configs -> ListTopicConfigsResponse.create( TopicConfigDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "configs")) .build()) .setData( configs.stream() .sorted(Comparator.comparing(TopicConfig::getName)) .map(this::toTopicConfigData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  TopicConfigsResource(
      Provider<TopicConfigManager> topicConfigManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.list") void listTopicConfigs(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName
  ); @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.get") void getTopicConfig(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("name") String name
  ); @PUT @Path("/{name}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.update") void updateTopicConfig(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("name") String name,
      @Valid UpdateTopicConfigRequest request
  ); @DELETE @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.delete") void resetTopicConfig(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("name") String name
  ); }
TopicConfigsResource { @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.list") public void listTopicConfigs( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName ) { CompletableFuture<ListTopicConfigsResponse> response = topicConfigManager.get() .listTopicConfigs(clusterId, topicName) .thenApply( configs -> ListTopicConfigsResponse.create( TopicConfigDataList.builder() .setMetadata( ResourceCollection.Metadata.builder() .setSelf( urlFactory.create( "v3", "clusters", clusterId, "topics", topicName, "configs")) .build()) .setData( configs.stream() .sorted(Comparator.comparing(TopicConfig::getName)) .map(this::toTopicConfigData) .collect(Collectors.toList())) .build())); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  TopicConfigsResource(
      Provider<TopicConfigManager> topicConfigManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); @GET @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.list") void listTopicConfigs(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName
  ); @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.get") void getTopicConfig(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("name") String name
  ); @PUT @Path("/{name}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.update") void updateTopicConfig(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("name") String name,
      @Valid UpdateTopicConfigRequest request
  ); @DELETE @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.delete") void resetTopicConfig(
      @Suspended AsyncResponse asyncResponse,
      @PathParam("clusterId") String clusterId,
      @PathParam("topicName") String topicName,
      @PathParam("name") String name
  );  }