Use yaml policies in models-examples

Now that yaml is supported, use those policies that are
stored in the models-examples that are preloaded into the
api.

Fixed a minor checkstyle issue. Not sure why it was missed.

Issue-ID: POLICY-2066
Change-Id: I2f4384a310bfa818555de5dacb477daf82fac6de
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
index 7551f7e..2d831f6 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
@@ -62,6 +62,7 @@
 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.coder.StandardYamlCoder;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
 import org.onap.policy.models.decisions.concepts.DecisionResponse;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -91,7 +92,7 @@
 
     private static final Logger LOGGER = LoggerFactory.getLogger(StdMatchableTranslator.class);
     private static final String POLICY_ID = "policy-id";
-    private static final StandardCoder standardCoder = new StandardCoder();
+    private static final StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
 
     private final Map<ToscaPolicyTypeIdentifier, ToscaPolicyType> matchablePolicyTypes = new HashMap<>();
     @Setter
@@ -549,7 +550,7 @@
         }
         LOGGER.info("Read in local policy type {}", policyTypePath.toAbsolutePath());
         try {
-            ToscaServiceTemplate serviceTemplate = standardCoder.decode(new String(bytes, StandardCharsets.UTF_8),
+            ToscaServiceTemplate serviceTemplate = standardYamlCoder.decode(new String(bytes, StandardCharsets.UTF_8),
                     ToscaServiceTemplate.class);
             JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate();
             jtst.fromAuthorative(serviceTemplate);
@@ -605,7 +606,7 @@
         // Store it locally
         //
         try {
-            standardCoder.encode(policyTypePath.toFile(), policyType);
+            standardYamlCoder.encode(policyTypePath.toFile(), policyType);
         } catch (CoderException e) {
             LOGGER.error("Failed to store {} locally to {}", policyTypeId, policyTypePath, e);
         }
@@ -617,6 +618,6 @@
 
     private Path constructLocalFilePath(ToscaPolicyTypeIdentifier policyTypeId) {
         return Paths.get(this.pathForData.toAbsolutePath().toString(), policyTypeId.getName() + "-"
-                + policyTypeId.getVersion() + ".json");
+                + policyTypeId.getVersion() + ".yaml");
     }
 }
diff --git a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
index b39f5c7..11a7a92 100644
--- a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
+++ b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
@@ -45,6 +45,7 @@
 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.common.utils.resources.TextFileUtils;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
 import org.onap.policy.models.decisions.concepts.DecisionResponse;
@@ -66,10 +67,17 @@
     private static StandardCoder gson = new StandardCoder();
     private static DecisionRequest requestAffinity;
     private static RestServerParameters clientParams;
-    private static String[] listPolicyTypeFiles = { "onap.policies.Optimization",
+    private static String[] listPolicyTypeFiles = {
+        "onap.policies.Optimization",
         "onap.policies.optimization.AffinityPolicy",
         "onap.policies.optimization.DistancePolicy",
-        "onap.policies.optimization.SubscriberPolicy"};
+        "onap.policies.optimization.HpaPolicy",
+        "onap.policies.optimization.OptimizationPolicy",
+        "onap.policies.optimization.PciPolicy",
+        "onap.policies.optimization.QueryPolicy",
+        "onap.policies.optimization.SubscriberPolicy",
+        "onap.policies.optimization.Vim_fit",
+        "onap.policies.optimization.VnfPolicy"};
 
     @ClassRule
     public static final TemporaryFolder policyFolder = new TemporaryFolder();
@@ -102,8 +110,10 @@
         // Copy the test policy types into data area
         //
         for (String policy : listPolicyTypeFiles) {
-            Files.copy(Paths.get("src/test/resources", policy + "-1.0.0.json"),
-                    Paths.get(policyFolder.getRoot().getAbsolutePath(), policy + "-1.0.0.json"));
+            String policyType = ResourceUtils.getResourceAsString("policytypes/" + policy + ".yaml");
+            LOGGER.info("Copying {}", policyType);
+            Files.write(Paths.get(policyFolder.getRoot().getAbsolutePath(), policy + "-1.0.0.yaml"),
+                    policyType.getBytes());
         }
         //
         // Load service
@@ -135,6 +145,7 @@
             strDump.append(System.lineSeparator());
         }
         LOGGER.debug("{}", strDump);
+        assertThat(service).isNotNull();
         //
         // Tell it to initialize based on the properties file
         // we just built for it.
diff --git a/applications/optimization/src/test/resources/onap.policies.Optimization-1.0.0.json b/applications/optimization/src/test/resources/onap.policies.Optimization-1.0.0.json
deleted file mode 100644
index 8ee418e..0000000
--- a/applications/optimization/src/test/resources/onap.policies.Optimization-1.0.0.json
+++ /dev/null
@@ -1,66 +0,0 @@
-{
-    "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
-    "policy_types": {
-        "onap.policies.Optimization": {
-            "derived_from": "tosca.policies.Root",
-            "version": "1.0.0",
-            "description": "The base policy type for all policies that govern optimization",
-            "properties": {
-                "scope": {
-                    "description": "Scope for the policy - could be for a specific release.",
-                    "type": "list",
-                    "metadata": {
-                        "matchable": true
-                    },
-                    "required": true
-                },
-                "services": {
-                    "description": "One or more services that the policy applies to.",
-                    "type": "list",
-                    "metadata": {
-                        "matchable": true
-                    },
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string"
-                    }
-                },
-                "resources": {
-                    "description": "One or more VNF resources that the policy applies to.",
-                    "type": "list",
-                    "metadata": {
-                        "matchable": true
-                    },
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string"
-                    }
-                },
-                "geography": {
-                    "description": "One or more geographic regions",
-                    "type": "list",
-                    "metadata": {
-                        "matchable": true
-                    },
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string",
-                        "constraints": [
-                            {
-                                "valid_values": [
-                                    "US",
-                                    "International"
-                                ]
-                            }
-                        ]
-                    }
-                },
-                "identity": {
-                    "description": "Used internally for identification",
-                    "type": "string",
-                    "required": true
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/applications/optimization/src/test/resources/onap.policies.optimization.AffinityPolicy-1.0.0.json b/applications/optimization/src/test/resources/onap.policies.optimization.AffinityPolicy-1.0.0.json
deleted file mode 100644
index d2b1b4b..0000000
--- a/applications/optimization/src/test/resources/onap.policies.optimization.AffinityPolicy-1.0.0.json
+++ /dev/null
@@ -1,54 +0,0 @@
-{
-    "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
-    "policy_types": {
-        "onap.policies.optimization.AffinityPolicy": {
-            "derived_from": "onap.policies.Optimization",
-            "version": "1.0.0",
-            "type_version": "1.0.0",
-            "properties": {
-                "applicableResources": {
-                    "type": "list",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string",
-                        "constraints": [
-                            {
-                                "valid_values": [
-                                    "any",
-                                    "all"
-                                ]
-                            }
-                        ]
-                    }
-                },
-                "affinityProperties": {
-                    "type": "policy.data.affinityProperties_properties",
-                    "required": true
-                }
-            }
-        }
-    },
-    "data_types": {
-        "policy.data.affinityProperties_properties": {
-            "derived_from": "tosca.nodes.Root",
-            "version": "1.0.0",
-            "properties": {
-                "qualifier": {
-                    "type": "string",
-                    "constraints": [
-                        {
-                            "valid_values": [
-                                "same",
-                                "different"
-                            ]
-                        }
-                    ]
-                },
-                "category": {
-                    "type": "string",
-                    "required": true
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/applications/optimization/src/test/resources/onap.policies.optimization.DistancePolicy-1.0.0.json b/applications/optimization/src/test/resources/onap.policies.optimization.DistancePolicy-1.0.0.json
deleted file mode 100644
index 1b74c35..0000000
--- a/applications/optimization/src/test/resources/onap.policies.optimization.DistancePolicy-1.0.0.json
+++ /dev/null
@@ -1,89 +0,0 @@
-{
-    "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
-    "policy_types": {
-        "onap.policies.optimization.DistancePolicy": {
-            "derived_from": "onap.policies.Optimization",
-            "version": "1.0.0",
-            "properties": {
-                "applicableResources": {
-                    "type": "list",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string",
-                        "constraints": [
-                            {
-                                "valid_values": [
-                                    "any",
-                                    "all"
-                                ]
-                            }
-                        ]
-                    }
-                },
-                "distanceProperties": {
-                    "type": "policy.data.distanceProperties_properties",
-                    "required": true
-                }
-            }
-        }
-    },
-    "data_types": {
-        "policy.data.distanceProperties_properties": {
-            "derived_from": "tosca.nodes.Root",
-            "properties": {
-                "locationInfo": {
-                    "type": "string",
-                    "required": true
-                },
-                "distance": {
-                    "type": "policy.data.distance_properties",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "policy.data.distance_properties"
-                    }
-                }
-            }
-        },
-        "policy.data.distance_properties": {
-            "derived_from": "tosca.nodes.Root",
-            "properties": {
-                "value": {
-                    "type": "string",
-                    "required": true
-                },
-                "operator": {
-                    "type": "list",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string",
-                        "constraints": [
-                            {
-                                "valid_values": [
-                                    "<",
-                                    "<=",
-                                    "\n",
-                                    ">=",
-                                    "="
-                                ]
-                            }
-                        ]
-                    }
-                },
-                "unit": {
-                    "type": "list",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string",
-                        "constraints": [
-                            {
-                                "valid_values": [
-                                    "km"
-                                ]
-                            }
-                        ]
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/applications/optimization/src/test/resources/onap.policies.optimization.SubscriberPolicy-1.0.0.json b/applications/optimization/src/test/resources/onap.policies.optimization.SubscriberPolicy-1.0.0.json
deleted file mode 100644
index a239d82..0000000
--- a/applications/optimization/src/test/resources/onap.policies.optimization.SubscriberPolicy-1.0.0.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
-    "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
-    "policy_types": {
-        "onap.policies.optimization.SubscriberPolicy": {
-            "derived_from": "onap.policies.Optimization",
-            "version": "1.0.0",
-            "properties": {
-                "subscriberProperties": {
-                    "type": "policy.data.subscriberProperties_properties",
-                    "required": true
-                }
-            }
-        }
-    },
-    "data_types": {
-        "policy.data.subscriberProperties_properties": {
-            "derived_from": "tosca.nodes.Root",
-            "properties": {
-                "subscriberName": {
-                    "type": "list",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string"
-                    }
-                },
-                "subscriberRole": {
-                    "type": "list",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string"
-                    }
-                },
-                "provStatus": {
-                    "type": "list",
-                    "required": true,
-                    "entry_schema": {
-                        "type": "string"
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
index 716e641..4244e56 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
@@ -244,7 +244,7 @@
     }
 
     /**
-     * Initializes the Monitoring application service
+     * Initializes the Monitoring application service.
      *
      * @param apps - the path to xacml.properties file
      */