summaryrefslogtreecommitdiffstats
path: root/runtime-acm
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2022-06-09 10:03:13 +0100
committeradheli.tavares <adheli.tavares@est.tech>2022-06-09 10:05:15 +0100
commitfe43edecef38cc06f7c540eaf43016e38f360227 (patch)
tree5b7535d3440c661385b3d2d02dff3652ab69b5e9 /runtime-acm
parente7deff07e3b30ef564ced876bdfe0b68911965a8 (diff)
Fix configuration for Prometheus metrics
JVM related metrics were not being exposed due to spring boot bug when loading beans configuration. Issue-ID: POLICY-4146 Change-Id: I334c60b0c0d087c63b28bf44704aa3e909eca646 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'runtime-acm')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java5
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java40
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java5
-rw-r--r--runtime-acm/src/main/resources/application.yaml3
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java20
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java16
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java12
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java26
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java45
-rw-r--r--runtime-acm/src/test/resources/application-test.yaml4
11 files changed, 101 insertions, 79 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java
index f51497266..6776e59a6 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
package org.onap.policy.clamp.acm.runtime.config;
-import java.util.Arrays;
import java.util.List;
import org.onap.policy.clamp.common.acm.rest.CoderHttpMesageConverter;
import org.springframework.context.annotation.Configuration;
@@ -38,7 +37,7 @@ public class ConverterConfiguration implements WebMvcConfigurer {
converters.add(new CoderHttpMesageConverter<>("json"));
StringHttpMessageConverter converter = new StringHttpMessageConverter();
- converter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
+ converter.setSupportedMediaTypes(List.of(MediaType.TEXT_PLAIN));
converters.add(converter);
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java
new file mode 100644
index 000000000..dca31cdb8
--- /dev/null
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.runtime.config;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MetricsConfiguration {
+
+ /**
+ * Load up the metrics registry.
+ */
+ @Bean
+ InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
+ return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
+ }
+}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java
index 7907de7be..107de58c9 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
* Common superclass to provide REST endpoints for the participant simulator.
*/
// @formatter:off
-@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML})
+@RequestMapping(value = "/onap/policy/clamp/acm/v2",
+ produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML})
@Api(value = "Automation Composition Commissioning API")
@SwaggerDefinition(
info = @Info(description =
diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml
index 0a5bb8b5d..21c754c1a 100644
--- a/runtime-acm/src/main/resources/application.yaml
+++ b/runtime-acm/src/main/resources/application.yaml
@@ -32,8 +32,6 @@ security:
server:
port: 6969
- servlet:
- context-path: /onap/policy/clamp/acm
error:
path: /error
@@ -62,5 +60,6 @@ runtime:
management:
endpoints:
web:
+ base-path: /
exposure:
include: health, metrics, prometheus
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
index a0f1a7590..cd6823257 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java
@@ -90,42 +90,42 @@ class CommissioningControllerTest extends CommonRestController {
}
@Test
- void testSwagger() throws Exception {
+ void testSwagger() {
super.testSwagger(COMMISSIONING_ENDPOINT);
}
@Test
- void testUnauthorizedCreate() throws Exception {
+ void testUnauthorizedCreate() {
assertUnauthorizedPost(COMMISSIONING_ENDPOINT, Entity.json(serviceTemplate));
}
@Test
- void testUnauthorizedQuery() throws Exception {
+ void testUnauthorizedQuery() {
assertUnauthorizedGet(COMMISSIONING_ENDPOINT);
}
@Test
- void testUnauthorizedQueryElements() throws Exception {
+ void testUnauthorizedQueryElements() {
assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/elements");
}
@Test
- void testUnauthorizedDelete() throws Exception {
+ void testUnauthorizedDelete() {
assertUnauthorizedDelete(COMMISSIONING_ENDPOINT);
}
@Test
- void testUnauthorizedQueryToscaServiceTemplate() throws Exception {
+ void testUnauthorizedQueryToscaServiceTemplate() {
assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/toscaservicetemplate");
}
@Test
- void testUnauthorizedQueryToscaServiceTemplateSchema() throws Exception {
+ void testUnauthorizedQueryToscaServiceTemplateSchema() {
assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/toscaServiceTemplateSchema");
}
@Test
- void testUnauthorizedQueryToscaServiceCommonOrInstanceProperties() throws Exception {
+ void testUnauthorizedQueryToscaServiceCommonOrInstanceProperties() {
assertUnauthorizedGet(COMMISSIONING_ENDPOINT + "/getCommonOrInstanceProperties");
}
@@ -170,7 +170,7 @@ class CommissioningControllerTest extends CommonRestController {
}
@Test
- void testCreateBadRequest() throws Exception {
+ void testCreateBadRequest() {
Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
Response resp = invocationBuilder.post(Entity.json("NotToscaServiceTempalte"));
@@ -181,7 +181,7 @@ class CommissioningControllerTest extends CommonRestController {
}
@Test
- void testCreate() throws Exception {
+ void testCreate() {
Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
Response resp = invocationBuilder.post(Entity.json(serviceTemplate));
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
index 49ed40ec8..b0359113b 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/InstantiationUtils.java
@@ -91,8 +91,8 @@ public class InstantiationUtils {
AutomationCompositions automationCompositions) {
assertThat(response).isNotNull();
assertThat(response.getErrorDetails()).isNull();
- assertThat(response.getAffectedAutomationCompositions().size())
- .isEqualTo(automationCompositions.getAutomationCompositionList().size());
+ assertThat(response.getAffectedAutomationCompositions())
+ .hasSameSizeAs(automationCompositions.getAutomationCompositionList());
for (AutomationComposition automationComposition : automationCompositions.getAutomationCompositionList()) {
assertTrue(response.getAffectedAutomationCompositions().stream()
.anyMatch(ac -> ac.equals(automationComposition.getKey().asIdentifier())));
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
index df21d3f00..35a3094cd 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
@@ -125,7 +125,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testSwagger() throws Exception {
+ void testSwagger() {
super.testSwagger(INSTANTIATION_ENDPOINT);
}
@@ -138,7 +138,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testQuery_Unauthorized() throws Exception {
+ void testQuery_Unauthorized() {
assertUnauthorizedGet(INSTANTIATION_ENDPOINT);
}
@@ -151,7 +151,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testDelete_Unauthorized() throws Exception {
+ void testDelete_Unauthorized() {
assertUnauthorizedDelete(INSTANTIATION_ENDPOINT);
}
@@ -214,7 +214,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testQuery_NoResultWithThisName() throws Exception {
+ void testQuery_NoResultWithThisName() {
Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName");
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
@@ -273,7 +273,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testDelete_NoResultWithThisName() throws Exception {
+ void testDelete_NoResultWithThisName() {
Invocation.Builder invocationBuilder =
super.sendRequest(INSTANTIATION_ENDPOINT + "?name=noResultWithThisName&version=1.0.1");
Response resp = invocationBuilder.delete();
@@ -325,7 +325,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testCreateInstanceProperties() throws Exception {
+ void testCreateInstanceProperties() {
Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES);
Response resp = invocationBuilder.post(Entity.json(serviceTemplate));
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
@@ -358,7 +358,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testDeleteInstancePropertiesBadRequest() throws Exception {
+ void testDeleteInstancePropertiesBadRequest() {
Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_PROPERTIES);
Response resp = invocationBuilder.post(Entity.json(serviceTemplate));
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
@@ -408,7 +408,7 @@ class InstantiationControllerTest extends CommonRestController {
}
@Test
- void testCommand_NotFound1() throws Exception {
+ void testCommand_NotFound1() {
Invocation.Builder invocationBuilder = super.sendRequest(INSTANTIATION_COMMAND_ENDPOINT);
Response resp = invocationBuilder.put(Entity.json(new InstantiationCommand()));
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), resp.getStatus());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java
index 0f9490d87..6a2b102fc 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/main/rest/ActuatorControllerTest.java
@@ -54,36 +54,36 @@ class ActuatorControllerTest extends CommonRestController {
}
@Test
- void testGetHealth_Unauthorized() throws Exception {
+ void testGetHealth_Unauthorized() {
assertUnauthorizedActGet(HEALTH_ENDPOINT);
}
@Test
- void testGetMetrics_Unauthorized() throws Exception {
+ void testGetMetrics_Unauthorized() {
assertUnauthorizedActGet(METRICS_ENDPOINT);
}
@Test
- void testGetPrometheus_Unauthorized() throws Exception {
+ void testGetPrometheus_Unauthorized() {
assertUnauthorizedActGet(PROMETHEUS_ENDPOINT);
}
@Test
- void testGetHealth() throws Exception {
+ void testGetHealth() {
Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGetMetrics() throws Exception {
+ void testGetMetrics() {
Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGePrometheus() throws Exception {
+ void testGetPrometheus() {
Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
index 6a53f6ce2..e8a8ad0c9 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/monitoring/rest/MonitoringQueryControllerTest.java
@@ -100,27 +100,27 @@ class MonitoringQueryControllerTest extends CommonRestController {
}
@Test
- void testQuery_Unauthorized_for_AcElementStats() throws Exception {
+ void testQuery_Unauthorized_for_AcElementStats() {
assertUnauthorizedGet(AC_ELEMENT_STATS_ENDPOINT);
}
@Test
- void testQuery_Unauthorized_for_AcParticipantStats() throws Exception {
+ void testQuery_Unauthorized_for_AcParticipantStats() {
assertUnauthorizedGet(PARTICIPANT_STATS_ENDPOINT);
}
@Test
- void testQuery_Unauthorized_for_ParticipantStatsPerAc() throws Exception {
+ void testQuery_Unauthorized_for_ParticipantStatsPerAc() {
assertUnauthorizedGet(PARTICIPANT_STATS_PER_AC_ENDPOINT);
}
@Test
- void testQuery_Unauthorized_for_AcElementStatsPerAc() throws Exception {
+ void testQuery_Unauthorized_for_AcElementStatsPerAc() {
assertUnauthorizedGet(AC_ELEMENT_STATS_PER_AC_ENDPOINT);
}
@Test
- void testSwagger_AcStats() throws Exception {
+ void testSwagger_AcStats() {
super.testSwagger(AC_ELEMENT_STATS_ENDPOINT);
super.testSwagger(PARTICIPANT_STATS_ENDPOINT);
super.testSwagger(AC_ELEMENT_STATS_PER_AC_ENDPOINT);
@@ -128,7 +128,7 @@ class MonitoringQueryControllerTest extends CommonRestController {
}
@Test
- void testAcElementStatisticsEndpoint() throws Exception {
+ void testAcElementStatisticsEndpoint() {
// Filter statistics only based on participant Id and UUID
Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?name="
+ acElementStatisticsList.getAcElementStatistics().get(0).getParticipantId().getName() + "&version="
@@ -164,14 +164,14 @@ class MonitoringQueryControllerTest extends CommonRestController {
}
@Test
- void testAcElementStats_BadRequest() throws Exception {
+ void testAcElementStats_BadRequest() {
Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_ENDPOINT + "?version=1.0.0");
Response response1 = invokeRequest1.buildGet().invoke();
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
}
@Test
- void testParticipantStatisticsEndpoint() throws Exception {
+ void testParticipantStatisticsEndpoint() {
// Filter statistics only based on participant Id
Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?name="
@@ -200,14 +200,14 @@ class MonitoringQueryControllerTest extends CommonRestController {
}
@Test
- void testParticipantStats_BadRequest() throws Exception {
+ void testParticipantStats_BadRequest() {
Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_ENDPOINT + "?version=0.0");
Response response1 = invokeRequest1.buildGet().invoke();
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
}
@Test
- void testParticipantStatsPerAcEndpoint() throws Exception {
+ void testParticipantStatsPerAcEndpoint() {
Invocation.Builder invokeRequest1 =
super.sendRequest(PARTICIPANT_STATS_PER_AC_ENDPOINT + "?name=dummyName&version=1.001");
Response response1 = invokeRequest1.buildGet().invoke();
@@ -217,14 +217,14 @@ class MonitoringQueryControllerTest extends CommonRestController {
}
@Test
- void testParticipantStatsPerAc_BadRequest() throws Exception {
+ void testParticipantStatsPerAc_BadRequest() {
Invocation.Builder invokeRequest1 = super.sendRequest(PARTICIPANT_STATS_PER_AC_ENDPOINT);
Response response1 = invokeRequest1.buildGet().invoke();
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
}
@Test
- void testAcElementStatisticsPerAcEndpoint() throws Exception {
+ void testAcElementStatisticsPerAcEndpoint() {
Invocation.Builder invokeRequest1 =
super.sendRequest(AC_ELEMENT_STATS_PER_AC_ENDPOINT + "?name=dummyName&version=1.001");
Response response1 = invokeRequest1.buildGet().invoke();
@@ -234,7 +234,7 @@ class MonitoringQueryControllerTest extends CommonRestController {
}
@Test
- void testAcElementStatsPerAc_BadRequest() throws Exception {
+ void testAcElementStatsPerAc_BadRequest() {
Invocation.Builder invokeRequest1 = super.sendRequest(AC_ELEMENT_STATS_PER_AC_ENDPOINT);
Response response1 = invokeRequest1.buildGet().invoke();
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response1.getStatus());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java
index 0fc0a6e9f..89d956aea 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,9 +42,8 @@ import org.onap.policy.common.utils.network.NetworkUtil;
public class CommonRestController {
public static final String SELF = NetworkUtil.getHostname();
- public static final String CONTEXT_PATH = "onap/automationcomposition";
+ public static final String CONTEXT_PATH = "onap/policy/clamp/acm";
public static final String ENDPOINT_PREFIX = CONTEXT_PATH + "/v2/";
- public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/";
private static String httpPrefix;
@@ -52,10 +51,9 @@ public class CommonRestController {
* Verifies that an endpoint appears within the swagger response.
*
* @param endpoint the endpoint of interest
- * @throws Exception if an error occurs
*/
- protected void testSwagger(final String endpoint) throws Exception {
- final Invocation.Builder invocationBuilder = sendRequest("api-docs");
+ protected void testSwagger(final String endpoint) {
+ final Invocation.Builder invocationBuilder = sendActRequest("v2/api-docs");
final String resp = invocationBuilder.get(String.class);
assertThat(resp).contains(endpoint);
@@ -66,9 +64,8 @@ public class CommonRestController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, true);
}
@@ -77,10 +74,9 @@ public class CommonRestController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendActRequest(final String endpoint) throws Exception {
- return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true);
+ protected Invocation.Builder sendActRequest(final String endpoint) {
+ return sendFqeRequest(httpPrefix + endpoint, true);
}
/**
@@ -88,9 +84,8 @@ public class CommonRestController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendNoAuthRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendNoAuthRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ENDPOINT_PREFIX + endpoint, false);
}
@@ -99,10 +94,9 @@ public class CommonRestController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception {
- return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false);
+ protected Invocation.Builder sendNoAuthActRequest(final String endpoint) {
+ return sendFqeRequest(httpPrefix + endpoint, false);
}
/**
@@ -111,10 +105,8 @@ public class CommonRestController {
* @param fullyQualifiedEndpoint the fully qualified target endpoint
* @param includeAuth if authorization header should be included
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth)
- throws Exception {
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) {
final Client client = ClientBuilder.newBuilder().build();
client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
@@ -134,9 +126,8 @@ public class CommonRestController {
*
* @param endPoint the endpoint
* @param entity the entity ofthe body
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedPost(final String endPoint, final Entity<?> entity) throws Exception {
+ protected void assertUnauthorizedPost(final String endPoint, final Entity<?> entity) {
Response rawresp = sendNoAuthRequest(endPoint).post(entity);
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
@@ -146,9 +137,8 @@ public class CommonRestController {
*
* @param endPoint the endpoint
* @param entity the entity ofthe body
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedPut(final String endPoint, final Entity<?> entity) throws Exception {
+ protected void assertUnauthorizedPut(final String endPoint, final Entity<?> entity) {
Response rawresp = sendNoAuthRequest(endPoint).put(entity);
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
@@ -157,9 +147,8 @@ public class CommonRestController {
* Assert that GET call is Unauthorized.
*
* @param endPoint the endpoint
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedGet(final String endPoint) throws Exception {
+ protected void assertUnauthorizedGet(final String endPoint) {
Response rawresp = sendNoAuthRequest(endPoint).buildGet().invoke();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
@@ -168,9 +157,8 @@ public class CommonRestController {
* Assert that GET call to actuator endpoint is Unauthorized.
*
* @param endPoint the endpoint
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedActGet(final String endPoint) throws Exception {
+ protected void assertUnauthorizedActGet(final String endPoint) {
Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
@@ -179,9 +167,8 @@ public class CommonRestController {
* Assert that DELETE call is Unauthorized.
*
* @param endPoint the endpoint
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedDelete(final String endPoint) throws Exception {
+ protected void assertUnauthorizedDelete(final String endPoint) {
Response rawresp = sendNoAuthRequest(endPoint).delete();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
diff --git a/runtime-acm/src/test/resources/application-test.yaml b/runtime-acm/src/test/resources/application-test.yaml
index 60a4d76a2..9d0754a29 100644
--- a/runtime-acm/src/test/resources/application-test.yaml
+++ b/runtime-acm/src/test/resources/application-test.yaml
@@ -12,10 +12,6 @@ spring:
hibernate:
dialect: org.hibernate.dialect.HSQLDialect
-server:
- servlet:
- context-path: /onap/automationcomposition
-
runtime:
participantParameters:
updateParameters: