@Test
public void testPolicySettingsValidation() 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);
    policyData.setApiflag("NOTAPI");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    List<Object> settings = new ArrayList<>();
    policyData.setSettings(settings);
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    settings.add("hello");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    settings.clear();
    Map<String, String> mapSetting = new LinkedHashMap<>();
    settings.add(mapSetting);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Settings Attributes</b>:<i> has one missing Attribute key");
    mapSetting.put("key", "value");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>", responseString);
    mapSetting.put("key", "");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>", responseString);
    mapSetting.clear();
    mapSetting.put("value", "thevalue");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("has one missing Attribute key");
    mapSetting.put("value", "$$$%%%");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("value has spaces or invalid characters");
}