Add yaml support to pap rest server 14/95614/1
authorjrh3 <jrh3@att.com>
Thu, 12 Sep 2019 18:34:30 +0000 (14:34 -0400)
committerjrh3 <jrh3@att.com>
Thu, 12 Sep 2019 19:28:41 +0000 (15:28 -0400)
Change-Id: I3e3d5c46bfa4f1d093e64b8be9a9720570e6000c
Issue-ID: POLICY-2085
Signed-off-by: jrh3 <jrh3@att.com>
main/src/main/java/org/onap/policy/pap/main/rest/PapRestControllerV1.java
main/src/test/java/org/onap/policy/pap/main/rest/PapRestControllerV1Test.java
pom.xml

index c4b7b4a..43b6b48 100644 (file)
@@ -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";
index 317ab1c..d8e6963 100644 (file)
 
 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;
@@ -40,6 +43,14 @@ public class PapRestControllerV1Test {
         bldr = Response.status(Response.Status.OK);
     }
 
+    @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();
diff --git a/pom.xml b/pom.xml
index 24a4a4e..f4e6d5b 100644 (file)
--- 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>