Fix simulator topics for lower case
[policy/models.git] / models-sim / models-sim-dmaap / src / main / java / org / onap / policy / models / sim / dmaap / provider / DmaapSimProvider.java
index d11d1b3..afbe10f 100644 (file)
@@ -1,7 +1,8 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
+ *  Copyright (C) 2019, 2023 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.
@@ -21,6 +22,8 @@
 
 package org.onap.policy.models.sim.dmaap.provider;
 
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -29,8 +32,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
 import lombok.Getter;
 import lombok.Setter;
 import org.onap.policy.common.utils.services.ServiceManagerContainer;
@@ -129,15 +130,9 @@ public class DmaapSimProvider extends ServiceManagerContainer {
             List<String> lst = topic2data.computeIfAbsent(topicName, this::makeTopicData).read(consumerGroup, limit,
                             timeoutMs);
 
-            if (lst.isEmpty() && timeoutMs > 0) {
-                LOGGER.debug("Topic: {}, Timed out waiting for messages: {}: {}", topicName, consumerGroup, consumerId);
-                return Response.status(Status.REQUEST_TIMEOUT).entity(lst).build();
-
-            } else {
-                LOGGER.debug("Topic: {}, Retrieved {} messages for: {}: {}", topicName, consumerGroup, lst.size(),
-                                consumerId);
-                return Response.status(Status.OK).entity(lst).build();
-            }
+            LOGGER.debug("Topic: {}, Retrieved {} messages for: {}: {}", topicName, lst.size(), consumerGroup,
+                            consumerId);
+            return Response.status(Status.OK).entity(lst).build();
 
         } catch (InterruptedException e) {
             LOGGER.warn("Topic: {}, Request for DMaaP message interrupted: {}: {}", topicName, consumerGroup,
@@ -147,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.
      */