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>
--- /dev/null
+/*-
+ * ============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;
+}
* ============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.
}
}
+ /**
+ * 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.
*/
* ============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.
/**
* 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";
* @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,
* @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();
+ }
}
/*-
* ============LICENSE_START=======================================================
* 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.
package org.onap.policy.models.sim.dmaap.rest;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import java.io.File;
resp = rest.getDmaapMessage(TOPIC, CONSUMER, CONSUMER_ID, LIMIT, 0);
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
assertEquals("[my-message, my-message-B]", resp.getEntity().toString());
+
+ // verify getDmaapTopics
+ resp = rest.getDmaapTopics();
+ assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
+ assertThat(resp.getEntity().toString()).contains("POLICY-PDP-PAP");
}
private int getCount(Response resp) {