summaryrefslogtreecommitdiffstats
path: root/models-sim/models-sim-dmaap/src/main/java
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2021-08-30 17:28:37 -0400
committerRam Krishna Verma <ram_krishna.verma@bell.ca>2021-08-31 09:06:27 -0400
commit263f2bd07273cef4bc103f5198fa36e1e04297e5 (patch)
tree5c3126f5f1999bce698fc431cc73f0c277eaaac3 /models-sim/models-sim-dmaap/src/main/java
parent62c469dc0045e81979ac14aecb105f2150592c3a (diff)
Add topics end point to dmaap sim
Add "/topics" end point to dmaap simulator. It will be used in CSIT tests to verify consolidated health check. Issue-ID: POLICY-3605 Change-Id: I6814d6dd021e0d98bd99754d4e68f789ef405353 Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
Diffstat (limited to 'models-sim/models-sim-dmaap/src/main/java')
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapGetTopicResponse.java37
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java15
-rw-r--r--models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java19
3 files changed, 68 insertions, 3 deletions
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapGetTopicResponse.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapGetTopicResponse.java
new file mode 100644
index 000000000..1f05976f7
--- /dev/null
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapGetTopicResponse.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Bell Canada. All rights reserved.
+ * ================================================================================
+ * 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.models.sim.dmaap.provider;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * Class to capture get topic response from dmaap simulator.
+ */
+@Getter
+@Setter
+@ToString
+public class DmaapGetTopicResponse {
+
+ private List<String> topics;
+}
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java
index c954ab8dc..2119a6521 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProvider.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -142,6 +143,20 @@ public class DmaapSimProvider extends ServiceManagerContainer {
}
/**
+ * Returns the list of default topics.
+ *
+ * @return the topic list
+ */
+ public Response processDmaapTopicsGet() {
+
+ LOGGER.debug("Request for listing DMaaP topics");
+ var response = new DmaapGetTopicResponse();
+ response.setTopics(List.of("POLICY-PDP-PAP", "POLICY-NOTIFICATION", "unauthenticated.DCAE_CL_OUTPUT",
+ "POLICY-CL-MGT"));
+ return Response.status(Status.OK).entity(response).build();
+ }
+
+ /**
* Task to remove idle consumers from each topic.
*/
private class SweeperTask implements Runnable {
diff --git a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java
index f6e14d2b0..17b7529f6 100644
--- a/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java
+++ b/models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019,2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +36,7 @@ import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider;
/**
* Class to provide REST endpoints for DMaaP simulator component statistics.
*/
-@Path("/events")
+@Path("/")
@Produces(DmaapSimRestControllerV1.MEDIA_TYPE_APPLICATION_JSON)
public class DmaapSimRestControllerV1 extends BaseRestControllerV1 {
public static final String MEDIA_TYPE_APPLICATION_JSON = "application/json";
@@ -50,7 +51,7 @@ public class DmaapSimRestControllerV1 extends BaseRestControllerV1 {
* @return the message
*/
@GET
- @Path("{topicName}/{consumerGroup}/{consumerId}")
+ @Path("events/{topicName}/{consumerGroup}/{consumerId}")
public Response getDmaapMessage(@PathParam("topicName") final String topicName,
@PathParam("consumerGroup") final String consumerGroup,
@PathParam("consumerId") final String consumerId,
@@ -68,11 +69,23 @@ public class DmaapSimRestControllerV1 extends BaseRestControllerV1 {
* @return the response to the post
*/
@POST
- @Path("{topicName}")
+ @Path("events/{topicName}")
@Consumes(value = {CambriaMessageBodyHandler.MEDIA_TYPE_APPLICATION_CAMBRIA,
TextMessageBodyHandler.MEDIA_TYPE_TEXT_PLAIN, MEDIA_TYPE_APPLICATION_JSON})
public Response postDmaapMessage(@PathParam("topicName") final String topicName, final Object dmaapMessage) {
return DmaapSimProvider.getInstance().processDmaapMessagePut(topicName, dmaapMessage);
}
+
+ /**
+ * Get the list of topics configured.
+ *
+ * @return the message
+ */
+ @GET
+ @Path("topics")
+ public Response getDmaapTopics() {
+
+ return DmaapSimProvider.getInstance().processDmaapTopicsGet();
+ }
}