@Test public void shouldRegisterPlugin() throws Exception { PluginReqisterQuery pluginReqisterQuery = new PluginReqisterQuery(); pluginReqisterQuery.setReturnCommands(true); pluginReqisterQuery.setReturnUpdatedCommands(true); pluginReqisterQuery.setReturnNotifications(true); PluginUpdate pluginUpdate = new PluginUpdate(); given(webSocketKafkaProxyConfig.getProxyPluginConnect()).willReturn(PROXY_PLUGIN_ENDPOINT); given(httpRestHelper.post(any(), any(), any(), any())).willReturn(createJwtTokenVO(ACCESS_TOKEN, REFRESH_TOKEN)); doAnswer(invocation -> { Object[] args = invocation.getArguments(); Request request = (Request)args[0]; ResponseConsumer responseConsumer = (ResponseConsumer)args[1]; responseConsumer.accept(Response.newBuilder() .withBody(request.getBody()) .buildSuccess()); return null; }).when(rpcClient).call(any(), any()); JsonObject actual = (JsonObject) pluginRegisterService.register(1L, pluginReqisterQuery, pluginUpdate, AUTHORIZATION).join().getEntity(); assertEquals(actual.get(ACCESS_TOKEN).getAsString(), ACCESS_TOKEN); assertEquals(actual.get(REFRESH_TOKEN).getAsString(), REFRESH_TOKEN); assertEquals(actual.get(PROXY_PLUGIN_ENDPOINT).getAsString(), PROXY_PLUGIN_ENDPOINT); verify(rpcClient, times(0)).call(any(), any()); }
public CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate, String authorization) { validateSubscription(pluginReqisterQuery); checkAuthServiceAvailable(); return persistPlugin(pluginUpdate, pluginReqisterQuery.constructFilterString(), userId).thenApply(pluginVO -> { JwtTokenVO jwtTokenVO = createPluginTokens(pluginVO.getTopicName(), authorization); JsonObject response = createTokenResponse(pluginVO.getTopicName(), jwtTokenVO); return ResponseFactory.response(CREATED, response, PLUGIN_SUBMITTED); }); }
PluginRegisterService { public CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate, String authorization) { validateSubscription(pluginReqisterQuery); checkAuthServiceAvailable(); return persistPlugin(pluginUpdate, pluginReqisterQuery.constructFilterString(), userId).thenApply(pluginVO -> { JwtTokenVO jwtTokenVO = createPluginTokens(pluginVO.getTopicName(), authorization); JsonObject response = createTokenResponse(pluginVO.getTopicName(), jwtTokenVO); return ResponseFactory.response(CREATED, response, PLUGIN_SUBMITTED); }); } }
PluginRegisterService { public CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate, String authorization) { validateSubscription(pluginReqisterQuery); checkAuthServiceAvailable(); return persistPlugin(pluginUpdate, pluginReqisterQuery.constructFilterString(), userId).thenApply(pluginVO -> { JwtTokenVO jwtTokenVO = createPluginTokens(pluginVO.getTopicName(), authorization); JsonObject response = createTokenResponse(pluginVO.getTopicName(), jwtTokenVO); return ResponseFactory.response(CREATED, response, PLUGIN_SUBMITTED); }); } @Autowired  PluginRegisterService(
            HiveValidator hiveValidator,
            PluginService pluginService,
            FilterService filterService, RpcClient rpcClient,
            KafkaTopicService kafkaTopicService,
            LongIdGenerator idGenerator,
            HttpRestHelper httpRestHelper,
            WebSocketKafkaProxyConfig webSocketKafkaProxyConfig,
            Gson gson); }
PluginRegisterService { public CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate, String authorization) { validateSubscription(pluginReqisterQuery); checkAuthServiceAvailable(); return persistPlugin(pluginUpdate, pluginReqisterQuery.constructFilterString(), userId).thenApply(pluginVO -> { JwtTokenVO jwtTokenVO = createPluginTokens(pluginVO.getTopicName(), authorization); JsonObject response = createTokenResponse(pluginVO.getTopicName(), jwtTokenVO); return ResponseFactory.response(CREATED, response, PLUGIN_SUBMITTED); }); } @Autowired  PluginRegisterService(
            HiveValidator hiveValidator,
            PluginService pluginService,
            FilterService filterService, RpcClient rpcClient,
            KafkaTopicService kafkaTopicService,
            LongIdGenerator idGenerator,
            HttpRestHelper httpRestHelper,
            WebSocketKafkaProxyConfig webSocketKafkaProxyConfig,
            Gson gson); CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate,
                                                String authorization); @Transactional CompletableFuture<Response> update(PluginVO existingPlugin, PluginUpdateQuery pluginUpdateQuery); @Transactional CompletableFuture<Response> delete(PluginVO existingPlugin); CompletableFuture<List<PluginVO>> list(String name, String namePattern, String topicName, Integer status, Long userId,
                                                  String sortField, String sortOrderSt, Integer take, Integer skip,
                                                  HivePrincipal principal); CompletableFuture<List<PluginVO>> list(ListPluginRequest listPluginRequest); CompletableFuture<EntityCountResponse> count(String name, String namePattern, String topicName,
                                                        Integer status, Long userId, HivePrincipal principal); CompletableFuture<EntityCountResponse> count(CountPluginRequest countPluginRequest); }
PluginRegisterService { public CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate, String authorization) { validateSubscription(pluginReqisterQuery); checkAuthServiceAvailable(); return persistPlugin(pluginUpdate, pluginReqisterQuery.constructFilterString(), userId).thenApply(pluginVO -> { JwtTokenVO jwtTokenVO = createPluginTokens(pluginVO.getTopicName(), authorization); JsonObject response = createTokenResponse(pluginVO.getTopicName(), jwtTokenVO); return ResponseFactory.response(CREATED, response, PLUGIN_SUBMITTED); }); } @Autowired  PluginRegisterService(
            HiveValidator hiveValidator,
            PluginService pluginService,
            FilterService filterService, RpcClient rpcClient,
            KafkaTopicService kafkaTopicService,
            LongIdGenerator idGenerator,
            HttpRestHelper httpRestHelper,
            WebSocketKafkaProxyConfig webSocketKafkaProxyConfig,
            Gson gson); CompletableFuture<Response> register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate,
                                                String authorization); @Transactional CompletableFuture<Response> update(PluginVO existingPlugin, PluginUpdateQuery pluginUpdateQuery); @Transactional CompletableFuture<Response> delete(PluginVO existingPlugin); CompletableFuture<List<PluginVO>> list(String name, String namePattern, String topicName, Integer status, Long userId,
                                                  String sortField, String sortOrderSt, Integer take, Integer skip,
                                                  HivePrincipal principal); CompletableFuture<List<PluginVO>> list(ListPluginRequest listPluginRequest); CompletableFuture<EntityCountResponse> count(String name, String namePattern, String topicName,
                                                        Integer status, Long userId, HivePrincipal principal); CompletableFuture<EntityCountResponse> count(CountPluginRequest countPluginRequest);  }