summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjrh3 <jrh3@att.com>2019-09-12 14:34:30 -0400
committerjrh3 <jrh3@att.com>2019-09-12 15:28:41 -0400
commitba11c9a1e41384fd065d4cb21beab3182651a066 (patch)
tree2c32ac274cab2585575846ab032f615d1f0d0ce5
parentad55e1eb6653c9b0ee9f68271b7bb2dc766a2c47 (diff)
Add yaml support to pap rest server
Change-Id: I3e3d5c46bfa4f1d093e64b8be9a9720570e6000c Issue-ID: POLICY-2085 Signed-off-by: jrh3 <jrh3@att.com>
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/PapRestControllerV1.java8
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/PapRestControllerV1Test.java11
-rw-r--r--pom.xml2
3 files changed, 17 insertions, 4 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/PapRestControllerV1.java b/main/src/main/java/org/onap/policy/pap/main/rest/PapRestControllerV1.java
index c4b7b4a4..43b6b48b 100644
--- a/main/src/main/java/org/onap/policy/pap/main/rest/PapRestControllerV1.java
+++ b/main/src/main/java/org/onap/policy/pap/main/rest/PapRestControllerV1.java
@@ -43,7 +43,7 @@ import org.onap.policy.models.base.PfModelException;
// @formatter:off
@Path("/policy/pap/v1")
@Api(value = "Policy Administration (PAP) API")
-@Produces(MediaType.APPLICATION_JSON)
+@Produces({MediaType.APPLICATION_JSON, PapRestControllerV1.APPLICATION_YAML})
@SwaggerDefinition(
info = @Info(description =
"Policy Administration is responsible for the deployment life cycle of policies as well as "
@@ -52,13 +52,15 @@ import org.onap.policy.models.base.PfModelException;
+ " ensuring that policies are available to users, that policies are executing correctly,"
+ " and that the state and status of policies is monitored", version = "v1.0",
title = "Policy Administration"),
- consumes = {MediaType.APPLICATION_JSON},
- produces = {MediaType.APPLICATION_JSON},
+ consumes = {MediaType.APPLICATION_JSON, PapRestControllerV1.APPLICATION_YAML},
+ produces = {MediaType.APPLICATION_JSON, PapRestControllerV1.APPLICATION_YAML},
schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
tags = {@Tag(name = "policy-administration", description = "Policy Administration Service Operations")},
securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
// @formatter:on
public class PapRestControllerV1 {
+ public static final String APPLICATION_YAML = "application/yaml";
+
public static final String EXTENSION_NAME = "interface info";
public static final String API_VERSION_NAME = "api-version";
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/PapRestControllerV1Test.java b/main/src/test/java/org/onap/policy/pap/main/rest/PapRestControllerV1Test.java
index 317ab1c1..d8e6963f 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/PapRestControllerV1Test.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/PapRestControllerV1Test.java
@@ -20,10 +20,13 @@
package org.onap.policy.pap.main.rest;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.UUID;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import org.junit.Before;
@@ -41,6 +44,14 @@ public class PapRestControllerV1Test {
}
@Test
+ public void testProduces() {
+ Produces annotation = PapRestControllerV1.class.getAnnotation(Produces.class);
+ assertNotNull(annotation);
+ assertThat(annotation.value()).contains(MediaType.APPLICATION_JSON)
+ .contains(PapRestControllerV1.APPLICATION_YAML);
+ }
+
+ @Test
public void testAddVersionControlHeaders() {
Response resp = ctlr.addVersionControlHeaders(bldr).build();
assertEquals("0", resp.getHeaderString(PapRestControllerV1.VERSION_MINOR_NAME));
diff --git a/pom.xml b/pom.xml
index 24a4a4e5..f4e6d5b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,7 @@
<sonar.jacoco.itReportPath>${project.basedir}/../target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
- <policy.common.version>1.5.2</policy.common.version>
+ <policy.common.version>1.6.0-SNAPSHOT</policy.common.version>
<policy.models.version>2.1.3</policy.models.version>
</properties>