summaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2023-01-24 15:50:27 +0000
committerFrancesco Davide Lapenta <francesco.lapenta@est.tech>2023-01-25 09:43:52 +0000
commit179fd9a931127160fb08aca517083de59c3e0c73 (patch)
tree23606c59025b41af0008177027d02421daa16d17 /main/src
parent09191f108632a46862ea7c60023ea5d012a81823 (diff)
Server Stubs PAP
Added "stub" profile with simple endpoint implementation Issue-ID: POLICY-4143 Change-Id: I8ad911f314e1d1428d05aa419f1322616d8ef835 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckRestControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyAuditControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/HealthCheckRestControllerV1Stub.java44
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupCreateOrUpdateControllerV1Stub.java48
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeleteControllerV1Stub.java59
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeployControllerV1Stub.java55
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupHealthCheckControllerV1Stub.java45
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupQueryControllerV1Stub.java45
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupStateChangeControllerV1Stub.java49
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyAuditControllerV1Stub.java86
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyComponentsHealthCheckControllerV1Stub.java45
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyStatusControllerV1Stub.java79
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java88
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java112
-rw-r--r--main/src/main/resources/application-stub.yaml3
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java2
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java2
36 files changed, 792 insertions, 12 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckRestControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckRestControllerV1.java
index 09aea852..8d4fd4b2 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckRestControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/HealthCheckRestControllerV1.java
@@ -24,6 +24,7 @@ package org.onap.policy.pap.main.rest;
import lombok.RequiredArgsConstructor;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -34,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class HealthCheckRestControllerV1 extends PapRestControllerV1 implements HealthCheckRestControllerV1Api {
private final HealthCheckProvider provider;
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java
index 8d8e35cc..b03006a5 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupCreateOrUpdateControllerV1.java
@@ -30,6 +30,7 @@ import org.onap.policy.models.pap.concepts.PdpGroupUpdateResponse;
import org.onap.policy.models.pdp.concepts.PdpGroups;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -38,6 +39,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PdpGroupCreateOrUpdateControllerV1 extends PapRestControllerV1
implements PdpGroupCreateOrUpdateControllerV1Api {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
index f6cec4ef..8188e8b7 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeleteControllerV1.java
@@ -38,6 +38,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierO
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -46,6 +47,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PdpGroupDeleteControllerV1 extends PapRestControllerV1
implements PdpGroupDeleteControllerV1Api {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java
index 62d0f369..2610170a 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupDeployControllerV1.java
@@ -38,6 +38,7 @@ import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -46,6 +47,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PdpGroupDeployControllerV1 extends PapRestControllerV1 implements PdpGroupDeployControllerV1Api {
public static final String POLICY_STATUS_URI = "/policy/pap/v1/policies/status";
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckControllerV1.java
index 0b08fa22..0f1ed2a2 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupHealthCheckControllerV1.java
@@ -29,6 +29,7 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -41,6 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PdpGroupHealthCheckControllerV1 extends PapRestControllerV1
implements PdpGroupHealthCheckControllerV1Api {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryControllerV1.java
index dccd5fb2..8d5496af 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupQueryControllerV1.java
@@ -29,6 +29,7 @@ import org.onap.policy.models.pdp.concepts.PdpGroups;
import org.onap.policy.pap.main.service.PdpGroupService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -40,6 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PdpGroupQueryControllerV1 extends PapRestControllerV1 implements PdpGroupQueryControllerV1Api {
private static final Logger LOGGER = LoggerFactory.getLogger(PdpGroupQueryControllerV1.class);
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java
index c67807cc..11917e4e 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PdpGroupStateChangeControllerV1.java
@@ -30,6 +30,7 @@ import org.onap.policy.models.pap.concepts.PdpGroupStateChangeResponse;
import org.onap.policy.models.pdp.enums.PdpState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -41,6 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PdpGroupStateChangeControllerV1 extends PapRestControllerV1 implements PdpGroupStateChangeControllerV1Api {
private static final Logger logger = LoggerFactory.getLogger(PdpGroupHealthCheckControllerV1.class);
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyAuditControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyAuditControllerV1.java
index 81681ff8..d360cb5a 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyAuditControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyAuditControllerV1.java
@@ -27,6 +27,7 @@ import lombok.RequiredArgsConstructor;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pap.concepts.PolicyAudit;
import org.onap.policy.pap.main.service.PolicyAuditService;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -37,6 +38,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PolicyAuditControllerV1 extends PapRestControllerV1 implements PolicyAuditControllerV1Api {
public static final String NO_AUDIT_RECORD_FOUND = "No records found matching the input parameters";
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java
index 2500c44f..34cde0d1 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyComponentsHealthCheckControllerV1.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -38,6 +39,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PolicyComponentsHealthCheckControllerV1 extends PapRestControllerV1
implements PolicyComponentsHealthCheckControllerV1Api {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java
index e1772142..dfa4ae9a 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PolicyStatusControllerV1.java
@@ -32,6 +32,7 @@ import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -42,6 +43,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class PolicyStatusControllerV1 extends PapRestControllerV1 implements PolicyStatusControllerV1Api {
private static final String EMPTY_REGEX_ERROR_MESSAGE = "An empty string passed as a regex is not allowed";
private static final String EMPTY_REGEX_WARNING = ". Empty string passed as Regex.";
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java
index 03ac3ba2..2af6e731 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/StatisticsRestControllerV1.java
@@ -29,6 +29,7 @@ import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.pap.main.service.PdpStatisticsService;
+import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@@ -39,6 +40,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequiredArgsConstructor
+@Profile("default")
public class StatisticsRestControllerV1 extends PapRestControllerV1
implements StatisticsRestControllerV1Api {
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/HealthCheckRestControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/HealthCheckRestControllerV1Stub.java
new file mode 100644
index 00000000..08bc645e
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/HealthCheckRestControllerV1Stub.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.pap.main.rest.HealthCheckRestControllerV1Api;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class HealthCheckRestControllerV1Stub extends PapRestControllerV1
+ implements HealthCheckRestControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<HealthCheckReport> healthcheck() {
+ return stubUtils.getStubbedResponse(HealthCheckReport.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupCreateOrUpdateControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupCreateOrUpdateControllerV1Stub.java
new file mode 100644
index 00000000..81ab6366
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupCreateOrUpdateControllerV1Stub.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.UUID;
+import javax.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pap.concepts.PdpGroupUpdateResponse;
+import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PdpGroupCreateOrUpdateControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PdpGroupCreateOrUpdateControllerV1Stub extends PapRestControllerV1
+ implements PdpGroupCreateOrUpdateControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<PdpGroupUpdateResponse> createOrUpdateGroups(
+ UUID requestId, @Valid PdpGroups body) {
+ return stubUtils.getStubbedResponse(PdpGroupUpdateResponse.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeleteControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeleteControllerV1Stub.java
new file mode 100644
index 00000000..9f464300
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeleteControllerV1Stub.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.UUID;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pap.concepts.PdpGroupDeleteResponse;
+import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PdpGroupDeleteControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PdpGroupDeleteControllerV1Stub extends PapRestControllerV1
+ implements PdpGroupDeleteControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<PdpGroupDeleteResponse> deleteGroup(
+ String name, UUID requestId) {
+ return stubUtils.getStubbedResponse(PdpGroupDeleteResponse.class);
+ }
+
+ @Override
+ public ResponseEntity<PdpGroupDeployResponse> deletePolicy(
+ String name, UUID requestId) {
+ return stubUtils.getStubbedResponse(PdpGroupDeployResponse.class);
+ }
+
+ @Override
+ public ResponseEntity<PdpGroupDeployResponse> deletePolicyVersion(
+ String name, String version, UUID requestId) {
+ return stubUtils.getStubbedResponse(PdpGroupDeployResponse.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeployControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeployControllerV1Stub.java
new file mode 100644
index 00000000..f9ed98e4
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupDeployControllerV1Stub.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.UUID;
+import javax.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pap.concepts.PdpDeployPolicies;
+import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse;
+import org.onap.policy.models.pdp.concepts.DeploymentGroups;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PdpGroupDeployControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PdpGroupDeployControllerV1Stub extends PapRestControllerV1
+ implements PdpGroupDeployControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<PdpGroupDeployResponse> deployPolicies(
+ UUID requestId, @Valid PdpDeployPolicies body) {
+ return stubUtils.getStubbedResponse(PdpGroupDeployResponse.class);
+ }
+
+ @Override
+ public ResponseEntity<PdpGroupDeployResponse> updateGroupPolicies(
+ UUID requestId, @Valid DeploymentGroups body) {
+ return stubUtils.getStubbedResponse(PdpGroupDeployResponse.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupHealthCheckControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupHealthCheckControllerV1Stub.java
new file mode 100644
index 00000000..a65f02bc
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupHealthCheckControllerV1Stub.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.UUID;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pdp.concepts.Pdps;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PdpGroupHealthCheckControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PdpGroupHealthCheckControllerV1Stub extends PapRestControllerV1
+ implements PdpGroupHealthCheckControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<Pdps> pdpGroupHealthCheck(UUID requestId) {
+ return stubUtils.getStubbedResponse(Pdps.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupQueryControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupQueryControllerV1Stub.java
new file mode 100644
index 00000000..12e44ac3
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupQueryControllerV1Stub.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.UUID;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PdpGroupQueryControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PdpGroupQueryControllerV1Stub extends PapRestControllerV1
+ implements PdpGroupQueryControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<PdpGroups> queryGroupDetails(UUID requestId) {
+ return stubUtils.getStubbedResponse(PdpGroups.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupStateChangeControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupStateChangeControllerV1Stub.java
new file mode 100644
index 00000000..dc4f236f
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PdpGroupStateChangeControllerV1Stub.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.UUID;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pap.concepts.PdpGroupStateChangeResponse;
+import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PdpGroupStateChangeControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PdpGroupStateChangeControllerV1Stub extends PapRestControllerV1
+ implements PdpGroupStateChangeControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<PdpGroupStateChangeResponse> changeGroupState(
+ String name, @NotNull @Valid PdpState state, UUID requestId) {
+ return stubUtils.getStubbedResponse(PdpGroupStateChangeResponse.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyAuditControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyAuditControllerV1Stub.java
new file mode 100644
index 00000000..b9f2c4e8
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyAuditControllerV1Stub.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.List;
+import java.util.UUID;
+import javax.validation.Valid;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pap.concepts.PolicyAudit;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PolicyAuditControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PolicyAuditControllerV1Stub extends PapRestControllerV1
+ implements PolicyAuditControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<List<PolicyAudit>> getAllAuditRecords(
+ UUID requestId,
+ @Min(1) @Max(100) @Valid Integer recordCount,
+ @Valid Long startTime,
+ @Valid Long endTime) {
+ return stubUtils.getStubbedResponseList(PolicyAudit.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> getAuditRecordsByGroup(
+ String pdpGroupName,
+ UUID requestId,
+ @Min(1) @Max(100) @Valid Integer recordCount,
+ @Valid Long startTime,
+ @Valid Long endTime) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> getAuditRecordsOfPolicy(
+ String policyName,
+ String policyVersion,
+ UUID requestId,
+ @Min(1) @Max(100) @Valid Integer recordCount,
+ @Valid Long startTime,
+ @Valid Long endTime) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> getAuditRecordsOfPolicyinPdpGroup(
+ String pdpGroupName,
+ String policyName,
+ String policyVersion,
+ UUID requestId,
+ @Min(1) @Max(100) @Valid Integer recordCount,
+ @Valid Long startTime,
+ @Valid Long endTime) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+} \ No newline at end of file
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyComponentsHealthCheckControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyComponentsHealthCheckControllerV1Stub.java
new file mode 100644
index 00000000..16773fa0
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyComponentsHealthCheckControllerV1Stub.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.Map;
+import java.util.UUID;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PolicyComponentsHealthCheckControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PolicyComponentsHealthCheckControllerV1Stub extends PapRestControllerV1
+ implements PolicyComponentsHealthCheckControllerV1Api {
+
+ private final StubUtils stubsUtils;
+
+ @Override
+ public ResponseEntity<Map<String, Object>> policyComponentsHealthCheck(UUID requestId) {
+ return stubsUtils.getStubbedResponseMap();
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyStatusControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyStatusControllerV1Stub.java
new file mode 100644
index 00000000..323320ab
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/PolicyStatusControllerV1Stub.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.UUID;
+import javax.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.PolicyStatusControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class PolicyStatusControllerV1Stub extends PapRestControllerV1
+ implements PolicyStatusControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<Object> getStatusOfAllPolicies(UUID requestId) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> getStatusOfPolicies(
+ String pdpGroupName, String policyName, UUID requestId) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> getStatusOfPoliciesByGroup(
+ String pdpGroupName, UUID requestId, @Valid String regex) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> getStatusOfPolicy(
+ String pdpGroupName, String policyName, String policyVersion, UUID requestId) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> queryAllDeployedPolicies(UUID requestId, @Valid String regex) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> queryDeployedPolicies(String name, UUID requestId) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+ @Override
+ public ResponseEntity<Object> queryDeployedPolicy(
+ String name, String version, UUID requestId) {
+ return stubUtils.getStubbedResponse(Object.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java
new file mode 100644
index 00000000..663f1acc
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StatisticsRestControllerV1Stub.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.onap.policy.pap.main.rest.StatisticsReport;
+import org.onap.policy.pap.main.rest.StatisticsRestControllerV1Api;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequiredArgsConstructor
+@Profile("stub")
+public class StatisticsRestControllerV1Stub extends PapRestControllerV1
+ implements StatisticsRestControllerV1Api {
+
+ private final StubUtils stubUtils;
+
+ @Override
+ public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpGroupStatistics(
+ String group,
+ UUID requestId,
+ @Valid Integer recordCount,
+ @Valid Long startTime,
+ @Valid Long endTime) {
+ return stubUtils.getStubbedResponseStatistics();
+ }
+
+ @Override
+ public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpInstanceStatistics(
+ String group,
+ String type,
+ String pdp,
+ UUID requestId,
+ @Valid Integer recordCount,
+ @Valid Long startTime,
+ @Valid Long endTime) {
+ return stubUtils.getStubbedResponseStatistics();
+ }
+
+ @Override
+ public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpStatistics(
+ UUID requestId, @Valid Integer recordCount, @Valid Long startTime, @Valid Long endTime) {
+ return stubUtils.getStubbedResponseStatistics();
+ }
+
+ @Override
+ public ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> pdpSubGroupStatistics(
+ String group,
+ String type,
+ UUID requestId,
+ @Valid Integer recordCount,
+ @Valid Long startTime,
+ @Valid Long endTime) {
+ return stubUtils.getStubbedResponseStatistics();
+ }
+
+ @Override
+ public ResponseEntity<StatisticsReport> statistics(UUID requestId) {
+ return stubUtils.getStubbedResponse(StatisticsReport.class);
+ }
+
+}
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
new file mode 100644
index 00000000..d2ab15fb
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/stub/StubUtils.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.pap.main.rest.stub;
+
+import com.google.gson.Gson;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.pap.main.rest.PapRestControllerV1;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Profile;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+@RequiredArgsConstructor
+@Service
+@Profile("stub")
+class StubUtils {
+ private static final Logger log = LoggerFactory.getLogger(StubUtils.class);
+ private final HttpServletRequest request;
+ private static final String ACCEPT = "Accept";
+ private static final String PAP_DB =
+ "/PapDb.json";
+ private static final Gson JSON_TRANSLATOR = new Gson();
+
+ <T> ResponseEntity<T> getStubbedResponse(Class<T> clazz) {
+ var accept = request.getHeader(ACCEPT);
+ if (accept != null && accept.contains("application/json")) {
+ final var resource = new ClassPathResource(PAP_DB);
+ try (var inputStream = resource.getInputStream()) {
+ final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
+ var targetObject = JSON_TRANSLATOR.fromJson(string, clazz);
+ return new ResponseEntity<>(targetObject, HttpStatus.OK);
+ } catch (IOException e) {
+ log.error("Couldn't serialize response for content type application/json", e);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ }
+
+ <T> ResponseEntity<List<T>> getStubbedResponseList(Class<T> clazz) {
+ var accept = request.getHeader(ACCEPT);
+ if (accept != null && accept.contains("application/json")) {
+ final var resource = new ClassPathResource(PAP_DB);
+ try (var inputStream = resource.getInputStream()) {
+ final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
+ var targetObject = Arrays.asList(JSON_TRANSLATOR.fromJson(string, clazz));
+ return new ResponseEntity<>(targetObject, HttpStatus.OK);
+ } catch (IOException e) {
+ log.error("Couldn't serialize response for content type application/json", e);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ }
+
+ ResponseEntity<Map<String, Object>> getStubbedResponseMap() {
+ var accept = request.getHeader(ACCEPT);
+ if (accept != null && accept.contains("application/json")) {
+ final var resource = new ClassPathResource(PAP_DB);
+ try (var inputStream = resource.getInputStream()) {
+ Map<String, Object> map = new HashMap<>();
+ final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
+ map.put(PapRestControllerV1.API_VERSION_NAME,
+ JSON_TRANSLATOR.fromJson(string, Object.class));
+ return new ResponseEntity<>(map, HttpStatus.OK);
+ } catch (IOException e) {
+ log.error("Couldn't serialize response for content type application/json", e);
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ }
+
+ ResponseEntity<Map<String, Map<String, List<PdpStatistics>>>> getStubbedResponseStatistics() {
+ var accept = request.getHeader(ACCEPT);
+ if (accept != null && accept.contains("application/json")) {
+ Map<String, Map<String, List<PdpStatistics>>> map = new HashMap<>();
+ return new ResponseEntity<>(map, HttpStatus.OK);
+ }
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ }
+
+}
diff --git a/main/src/main/resources/application-stub.yaml b/main/src/main/resources/application-stub.yaml
new file mode 100644
index 00000000..b509fd69
--- /dev/null
+++ b/main/src/main/resources/application-stub.yaml
@@ -0,0 +1,3 @@
+spring:
+ application:
+ name: "policy-api-stub" \ No newline at end of file
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java
index 14fa42d0..e5823bc3 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestHealthCheckRestControllerV1.java
@@ -39,7 +39,7 @@ import org.springframework.test.context.ActiveProfiles;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestHealthCheckRestControllerV1 extends CommonPapRestServer {
private static final String HEALTHCHECK_ENDPOINT = "healthcheck";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java
index 6649dc7b..c5442fad 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateControllerV1.java
@@ -38,7 +38,7 @@ import org.springframework.test.context.ActiveProfiles;
/**
* Note: this tests failure cases; success cases are tested by tests in the "e2e" package.
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPdpGroupCreateOrUpdateControllerV1 extends CommonPapRestServer {
private static final String CREATEORUPDATE_GROUPS_ENDPOINT = "pdps/groups/batch";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java
index 033461f7..21640bf9 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteControllerV1.java
@@ -33,7 +33,7 @@ import org.springframework.test.context.ActiveProfiles;
/**
* Note: this tests failure cases; success cases are tested by tests in the "e2e" package.
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPdpGroupDeleteControllerV1 extends CommonPapRestServer {
private static final String GROUP_NOT_FOUND = "group not found";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java
index 5d48ecc7..61d204c9 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java
@@ -42,7 +42,7 @@ import org.springframework.test.context.ActiveProfiles;
/**
* Note: this tests failure cases; success cases are tested by tests in the "e2e" package.
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPdpGroupDeployControllerV1 extends CommonPapRestServer {
private static final String DEPLOY_GROUP_ENDPOINT = "pdps/deployments/batch";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java
index f149d3ed..f935f923 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupHealthCheckControllerV1.java
@@ -35,7 +35,7 @@ import org.springframework.test.context.ActiveProfiles;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPdpGroupHealthCheckControllerV1 extends CommonPapRestServer {
private static final String ENDPOINT = "pdps/healthcheck";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java
index 255718b9..30cd5944 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupQueryControllerV1.java
@@ -35,7 +35,7 @@ import org.springframework.test.context.ActiveProfiles;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPdpGroupQueryControllerV1 extends CommonPapRestServer {
private static final String GROUP_ENDPOINT = "pdps";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java
index 6762c49c..a92731ab 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupStateChangeControllerV1.java
@@ -35,7 +35,7 @@ import org.springframework.test.context.ActiveProfiles;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPdpGroupStateChangeControllerV1 extends CommonPapRestServer {
private static final String GROUP_ENDPOINT = "pdps/groups";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java
index 23fa803a..3764e211 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyAuditControllerV1.java
@@ -29,7 +29,7 @@ import org.springframework.test.context.ActiveProfiles;
/**
* Note: this tests failure cases; success cases are tested by tests in the "e2e" package.
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPolicyAuditControllerV1 extends CommonPapRestServer {
private static final String POLICY_AUDIT_ENDPOINT = "policies/audit";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java
index 9eec5e1e..ff91ebe9 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckControllerV1.java
@@ -42,7 +42,7 @@ import org.springframework.test.context.ActiveProfiles;
*
* @author Yehui Wang (yehui.wang@est.tech)
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPolicyComponentsHealthCheckControllerV1 extends CommonPapRestServer {
private static final String ENDPOINT = "components/healthcheck";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java
index 907e6c5a..41cfd39d 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyStatusControllerV1.java
@@ -34,7 +34,7 @@ import org.springframework.test.context.ActiveProfiles;
/**
* Note: this tests failure cases; success cases are tested by tests in the "e2e" package.
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestPolicyStatusControllerV1 extends CommonPapRestServer {
private static final String POLICY_STATUS_ENDPOINT = "policies/deployed";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java
index e19bdb85..423c1d33 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java
@@ -34,7 +34,7 @@ import org.springframework.test.context.ActiveProfiles;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@ActiveProfiles("test")
+@ActiveProfiles({ "test", "default" })
public class TestStatisticsRestControllerV1 extends CommonPapRestServer {
private static final String STATISTICS_ENDPOINT = "statistics";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
index 48bc1e05..fd74caa2 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
@@ -59,7 +59,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
import org.yaml.snakeyaml.Yaml;
-@ActiveProfiles("test-e2e")
+@ActiveProfiles({ "test-e2e", "default" })
public abstract class End2EndBase extends CommonPapRestServer {
private static final Logger logger = LoggerFactory.getLogger(End2EndBase.class);