@Test public void getTopicConfig_nonExistingConfig_throwsNotFound() { expect( topicConfigManager.getTopicConfig( CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName())) .andReturn(completedFuture(Optional.empty())); replay(topicConfigManager); FakeAsyncResponse response = new FakeAsyncResponse(); topicConfigsResource.getTopicConfig( response, CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName()); assertEquals(NotFoundException.class, response.getException().getClass()); }
@GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.get") public void getTopicConfig( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("name") String name ) { CompletableFuture<GetTopicConfigResponse> response = topicConfigManager.get() .getTopicConfig(clusterId, topicName, name) .thenApply(topic -> topic.orElseThrow(NotFoundException::new)) .thenApply(topic -> GetTopicConfigResponse.create(toTopicConfigData(topic))); AsyncResponses.asyncResume(asyncResponse, response); }
TopicConfigsResource { @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.get") public void getTopicConfig( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("name") String name ) { CompletableFuture<GetTopicConfigResponse> response = topicConfigManager.get() .getTopicConfig(clusterId, topicName, name) .thenApply(topic -> topic.orElseThrow(NotFoundException::new)) .thenApply(topic -> GetTopicConfigResponse.create(toTopicConfigData(topic))); AsyncResponses.asyncResume(asyncResponse, response); } }
TopicConfigsResource { @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.get") public void getTopicConfig( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("name") String name ) { CompletableFuture<GetTopicConfigResponse> response = topicConfigManager.get() .getTopicConfig(clusterId, topicName, name) .thenApply(topic -> topic.orElseThrow(NotFoundException::new)) .thenApply(topic -> GetTopicConfigResponse.create(toTopicConfigData(topic))); AsyncResponses.asyncResume(asyncResponse, response); } @Inject  TopicConfigsResource(
      Provider<TopicConfigManager> topicConfigManager,
      CrnFactory crnFactory,
      UrlFactory urlFactory); }
TopicConfigsResource { @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.get") public void getTopicConfig( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("name") String name ) { CompletableFuture<GetTopicConfigResponse> response = topicConfigManager.get() .getTopicConfig(clusterId, topicName, name) .thenApply(topic -> topic.orElseThrow(NotFoundException::new)) .thenApply(topic -> GetTopicConfigResponse.create(toTopicConfigData(topic))); 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 @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @PerformanceMetric("v3.topics.configs.get") public void getTopicConfig( @Suspended AsyncResponse asyncResponse, @PathParam("clusterId") String clusterId, @PathParam("topicName") String topicName, @PathParam("name") String name ) { CompletableFuture<GetTopicConfigResponse> response = topicConfigManager.get() .getTopicConfig(clusterId, topicName, name) .thenApply(topic -> topic.orElseThrow(NotFoundException::new)) .thenApply(topic -> GetTopicConfigResponse.create(toTopicConfigData(topic))); 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
  );  }