@Test
public void testPolicyConfigCloseLoopPmValidation() throws IOException {

    PolicyValidation validation = new PolicyValidation();
    PolicyRestAdapter policyData = new PolicyRestAdapter();
    policyData.setPolicyName("ALegalPolicyName");
    policyData.setPolicyDescription("A Valid Description");
    String responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    policyData.setApiflag("API");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    // Invalid values tested in config base test
    policyData.setOnapName("AValidOnapName");
    policyData.setRiskType("AValidRiskType");
    policyData.setRiskLevel("AValidRiskLevel");
    policyData.setGuard("AValidGuard");
    assertEquals("success", responseString);
    policyData.setPolicyType("Config");
    policyData.setConfigPolicyType("ClosedLoop_PM");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("ServiceType PolicyName is required");
    Map<String, String> serviceTypePolicyName = null;
    policyData.setServiceTypePolicyName(serviceTypePolicyName);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("ServiceType PolicyName is required");
    serviceTypePolicyName = new LinkedHashMap<>();
    policyData.setServiceTypePolicyName(serviceTypePolicyName);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("ServiceType PolicyName is required");
    serviceTypePolicyName.put("AKey", "AValue");
    policyData.setServiceTypePolicyName(serviceTypePolicyName);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("ServiceType PolicyName is required");
    serviceTypePolicyName.clear();
    serviceTypePolicyName.put("serviceTypePolicyName", "");
    policyData.setServiceTypePolicyName(serviceTypePolicyName);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("ServiceType PolicyName is required");
    serviceTypePolicyName.put("serviceTypePolicyName", "AValidserviceTypePolicyName");
    policyData.setServiceTypePolicyName(serviceTypePolicyName);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    policyData.setJsonBody("");
    assertNull(validation.validatePolicy(policyData));
    policyData.setJsonBody("InvalidConfigBodyData");
    assertNull(validation.validatePolicy(policyData));
    policyData.setJsonBody("{}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    policyData.setJsonBody("{\"gamma\": false}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    policyData.setJsonBody("{\"gamma\": true}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"mcr\": false}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    policyData.setJsonBody("{\"mcr\": true}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": false}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    policyData.setJsonBody("{\"trinity\": true}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"vDNS\": false}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    policyData.setJsonBody("{\"vDNS\": true}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"vUSP\": false}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    policyData.setJsonBody("{\"vUSP\": true}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": null}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Email Address is not Valid");
    policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"%%%$$$\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Email Address is not Valid");
    policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"dorothy@emealdcity.oz\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"geoLink\": null}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"geoLink\": \"\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"geoLink\": \"$$$%%%\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("The Value in Required Field");
    policyData.setJsonBody("{\"trinity\": true, \"geoLink\": \"AValidGeoLink\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"attributes\": null}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"attributes\": {}}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"attributes\": {\"an0\":\"av0\"}}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
    policyData.setJsonBody("{\"trinity\": true, \"attributes\": {\"an0\":\"$$$%%%\"}}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("value has spaces or invalid characters");
    policyData.setJsonBody("{\"trinity\": true, \"attributes\": {\"Message\":\"$$$%%%\"}}");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
}