@Test public void getTopicConfig_existingConfig_returnsConfig() { expect( topicConfigManager.getTopicConfig( CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName())) .andReturn(completedFuture(Optional.of(CONFIG_1))); replay(topicConfigManager); FakeAsyncResponse response = new FakeAsyncResponse(); topicConfigsResource.getTopicConfig(response, CLUSTER_ID, TOPIC_NAME, CONFIG_1.getName()); GetTopicConfigResponse expected = GetTopicConfigResponse.create( TopicConfigData.builder() .setMetadata( Resource.Metadata.builder() .setSelf( "/v3/clusters/cluster-1/topics/topic-1/configs/config-1") .setResourceName( "crn: .build()) .setClusterId(CLUSTER_ID) .setTopicName(TOPIC_NAME) .setName(CONFIG_1.getName()) .setValue(CONFIG_1.getValue()) .setDefault(CONFIG_1.isDefault()) .setReadOnly(CONFIG_1.isReadOnly()) .setSensitive(CONFIG_1.isSensitive()) .setSource(CONFIG_1.getSource()) .setSynonyms( CONFIG_1.getSynonyms().stream() .map(ConfigSynonymData::fromConfigSynonym) .collect(Collectors.toList())) .build()); assertEquals(expected, response.getValue()); }
@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
  );  }