From 263f2bd07273cef4bc103f5198fa36e1e04297e5 Mon Sep 17 00:00:00 2001 From: Ram Krishna Verma Date: Mon, 30 Aug 2021 17:28:37 -0400 Subject: 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 --- .../sim/dmaap/provider/DmaapGetTopicResponse.java | 37 ++++++++++++++++++++++ .../sim/dmaap/provider/DmaapSimProvider.java | 15 +++++++++ .../sim/dmaap/rest/DmaapSimRestControllerV1.java | 19 +++++++++-- 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/provider/DmaapGetTopicResponse.java (limited to 'models-sim/models-sim-dmaap/src/main/java') 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 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. @@ -141,6 +142,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. */ 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(); + } } -- cgit 1.2.3-korg