From a5b1e72e430289017a12be11338b580b417406de Mon Sep 17 00:00:00 2001 From: GaneshSPatil Date: Tue, 9 Apr 2019 09:54:19 +0530 Subject: [PATCH] Change Elastic Agent Extension v5 API call names (#5538) Change following plugin api call: * 'get-profile-metadata' => 'get-elastic-agent-profile-metadata' * 'get-profile-view' => 'get-elastic-agent-profile-view' * 'validate-profile' => 'validate-elastic-agent-profile' --- .../elastic/v5/ElasticAgentExtensionV5.java | 6 ++--- .../v5/ElasticAgentPluginConstantsV5.java | 6 ++--- .../elastic/ElasticAgentExtensionV4Test.java | 7 +++++ .../elastic/ElasticAgentExtensionV5Test.java | 26 ++++++++++++++----- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentExtensionV5.java b/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentExtensionV5.java index 5b5280e8dd2..03dc6fc14f7 100644 --- a/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentExtensionV5.java +++ b/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentExtensionV5.java @@ -63,7 +63,7 @@ public Capabilities onSuccess(String responseBody, Map responseH @Override public List getElasticProfileMetadata(String pluginId) { - return pluginRequestHelper.submitRequest(pluginId, REQUEST_GET_PROFILE_METADATA, new DefaultPluginInteractionCallback>() { + return pluginRequestHelper.submitRequest(pluginId, REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA, new DefaultPluginInteractionCallback>() { @Override public List onSuccess(String responseBody, Map responseHeaders, String resolvedExtensionVersion) { return elasticAgentExtensionConverterV5.getElasticProfileMetadataResponseFromBody(responseBody); @@ -73,7 +73,7 @@ public List onSuccess(String responseBody, Map() { + return pluginRequestHelper.submitRequest(pluginId, REQUEST_GET_ELASTIC_AGENT_PROFILE_VIEW, new DefaultPluginInteractionCallback() { @Override public String onSuccess(String responseBody, Map responseHeaders, String resolvedExtensionVersion) { return elasticAgentExtensionConverterV5.getProfileViewResponseFromBody(responseBody); @@ -88,7 +88,7 @@ public boolean supportsClusterProfile() { @Override public ValidationResult validateElasticProfile(final String pluginId, final Map configuration) { - return pluginRequestHelper.submitRequest(pluginId, REQUEST_VALIDATE_PROFILE, new DefaultPluginInteractionCallback() { + return pluginRequestHelper.submitRequest(pluginId, REQUEST_VALIDATE_ELASTIC_AGENT_PROFILE, new DefaultPluginInteractionCallback() { @Override public String requestBody(String resolvedExtensionVersion) { return elasticAgentExtensionConverterV5.validateElasticProfileRequestBody(configuration); diff --git a/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentPluginConstantsV5.java b/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentPluginConstantsV5.java index 0b7f425505f..97845d9de2e 100644 --- a/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentPluginConstantsV5.java +++ b/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ElasticAgentPluginConstantsV5.java @@ -23,9 +23,9 @@ public interface ElasticAgentPluginConstantsV5 { String REQUEST_SERVER_PING = REQUEST_PREFIX + ".server-ping"; String REQUEST_SHOULD_ASSIGN_WORK = REQUEST_PREFIX + ".should-assign-work"; - String REQUEST_GET_PROFILE_METADATA = REQUEST_PREFIX + ".get-profile-metadata"; - String REQUEST_GET_PROFILE_VIEW = REQUEST_PREFIX + ".get-profile-view"; - String REQUEST_VALIDATE_PROFILE = REQUEST_PREFIX + ".validate-profile"; + String REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA = REQUEST_PREFIX + ".get-elastic-agent-profile-metadata"; + String REQUEST_GET_ELASTIC_AGENT_PROFILE_VIEW = REQUEST_PREFIX + ".get-elastic-agent-profile-view"; + String REQUEST_VALIDATE_ELASTIC_AGENT_PROFILE = REQUEST_PREFIX + ".validate-elastic-agent-profile"; String REQUEST_GET_PLUGIN_SETTINGS_ICON = REQUEST_PREFIX + ".get-icon"; String REQUEST_GET_CLUSTER_PROFILE_METADATA = REQUEST_PREFIX + ".get-cluster-profile-metadata"; diff --git a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV4Test.java b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV4Test.java index adf844a5c8d..3063583cf58 100644 --- a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV4Test.java +++ b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV4Test.java @@ -311,6 +311,13 @@ public void shouldNotSupportGetClusterProfileStatusReportCall() { extensionV4.getClusterStatusReport(PLUGIN_ID, new HashMap<>()); } + @Test + public void shouldVerifyPluginApiRequestNamesOfElasticAgentProfile() { + assertThat(REQUEST_GET_PROFILE_METADATA, is(String.format("%s.get-profile-metadata", REQUEST_PREFIX))); + assertThat(REQUEST_GET_PROFILE_VIEW, is(String.format("%s.get-profile-view", REQUEST_PREFIX))); + assertThat(REQUEST_VALIDATE_PROFILE, is(String.format("%s.validate-profile", REQUEST_PREFIX))); + } + @Test public void allRequestMustHaveRequestPrefix() { assertThat(REQUEST_PREFIX, is("cd.go.elastic-agent")); diff --git a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV5Test.java b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV5Test.java index cf0e5466851..3f241a73091 100644 --- a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV5Test.java +++ b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentExtensionV5Test.java @@ -120,7 +120,7 @@ public void shouldGetProfileMetadata() { new PluginConfiguration("Password", new Metadata(true, true)) )); - assertExtensionRequest("5.0", REQUEST_GET_PROFILE_METADATA, null); + assertExtensionRequest("5.0", REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA, null); } @Test @@ -132,7 +132,7 @@ public void shouldGetProfileView() { assertThat(view, is("
This is profile view snippet
")); - assertExtensionRequest("5.0", REQUEST_GET_PROFILE_VIEW, null); + assertExtensionRequest("5.0", REQUEST_GET_ELASTIC_AGENT_PROFILE_VIEW, null); } @Test @@ -148,7 +148,7 @@ public void shouldValidateProfile() { new ValidationError("SearchBase", "SearchBase must not be blank.") )); - assertExtensionRequest("5.0", REQUEST_VALIDATE_PROFILE, "{}"); + assertExtensionRequest("5.0", REQUEST_VALIDATE_ELASTIC_AGENT_PROFILE, "{}"); } @@ -404,6 +404,20 @@ public void shouldGetClusterStatusReport() { assertExtensionRequest("5.0", REQUEST_CLUSTER_STATUS_REPORT, requestBody); } + @Test + public void shouldVerifyPluginApiRequestNamesOfElasticAgentProfile() { + assertThat(REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA, is(String.format("%s.get-elastic-agent-profile-metadata", REQUEST_PREFIX))); + assertThat(REQUEST_GET_ELASTIC_AGENT_PROFILE_VIEW, is(String.format("%s.get-elastic-agent-profile-view", REQUEST_PREFIX))); + assertThat(REQUEST_VALIDATE_ELASTIC_AGENT_PROFILE, is(String.format("%s.validate-elastic-agent-profile", REQUEST_PREFIX))); + } + + @Test + public void shouldVerifyPluginApiRequestNamesOfClusterProfile() { + assertThat(REQUEST_GET_CLUSTER_PROFILE_METADATA, is(String.format("%s.get-cluster-profile-metadata", REQUEST_PREFIX))); + assertThat(REQUEST_GET_CLUSTER_PROFILE_VIEW, is(String.format("%s.get-cluster-profile-view", REQUEST_PREFIX))); + assertThat(REQUEST_VALIDATE_CLUSTER_PROFILE, is(String.format("%s.validate-cluster-profile", REQUEST_PREFIX))); + } + @Test public void allRequestMustHaveRequestPrefix() { assertThat(REQUEST_PREFIX, is("cd.go.elastic-agent")); @@ -412,9 +426,9 @@ public void allRequestMustHaveRequestPrefix() { assertThat(REQUEST_SERVER_PING, Matchers.startsWith(REQUEST_PREFIX)); assertThat(REQUEST_SHOULD_ASSIGN_WORK, Matchers.startsWith(REQUEST_PREFIX)); - assertThat(REQUEST_GET_PROFILE_METADATA, Matchers.startsWith(REQUEST_PREFIX)); - assertThat(REQUEST_GET_PROFILE_VIEW, Matchers.startsWith(REQUEST_PREFIX)); - assertThat(REQUEST_VALIDATE_PROFILE, Matchers.startsWith(REQUEST_PREFIX)); + assertThat(REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA, Matchers.startsWith(REQUEST_PREFIX)); + assertThat(REQUEST_GET_ELASTIC_AGENT_PROFILE_VIEW, Matchers.startsWith(REQUEST_PREFIX)); + assertThat(REQUEST_VALIDATE_ELASTIC_AGENT_PROFILE, Matchers.startsWith(REQUEST_PREFIX)); assertThat(REQUEST_GET_PLUGIN_SETTINGS_ICON, Matchers.startsWith(REQUEST_PREFIX)); }