@Test
public void testPolicyRuleAlgorithmsValidation() 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> ruleAlgorithmschoices = new ArrayList<>();
    policyData.setRuleAlgorithmschoices(ruleAlgorithmschoices);
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    ruleAlgorithmschoices.add("hello");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    ruleAlgorithmschoices.clear();
    Map<String, String> mapChoice = new LinkedHashMap<>();
    ruleAlgorithmschoices.add(mapChoice);
    assertNull(validation.validatePolicy(policyData));
    mapChoice.clear();
    mapChoice.put("id", "TheID");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Field 1 value is not selected");
    mapChoice.put("dynamicRuleAlgorithmField1", "Field1");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Field 2 value is not selected");
    mapChoice.put("dynamicRuleAlgorithmCombo", "Combo");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Field 3 value is empty");
    mapChoice.put("dynamicRuleAlgorithmField2", "Field2");
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success", responseString);
    mapChoice.put("dynamicRuleAlgorithmField2", "%%%$$$");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Field 3 value has special characters");
}