@Test
public void testPolicyConfigCloseLoopFaultValidation() 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_Fault");
    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("There were no conditions provided in configBody json");
    policyData.setJsonBody("{\"conditions\": null}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("There were no conditions provided in configBody json");
    policyData.setJsonBody("{\"conditions\": \"\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select At least one Condition");
    policyData.setJsonBody("{\"conditions\": \"AValidCondition\"}");
    assertNull(validation.validatePolicy(policyData));
    policyData.setApiflag("NOAPI");
    policyData.setJsonBody("");
    assertNull(validation.validatePolicy(policyData));
    policyData.setJsonBody("InvalidConfigBodyData");
    assertNull(validation.validatePolicy(policyData));
    ClosedLoopFaultTrapDatas trapDatas = new ClosedLoopFaultTrapDatas();
    policyData.setTrapDatas(trapDatas);
    ClosedLoopFaultTrapDatas faultDatas = new ClosedLoopFaultTrapDatas();
    policyData.setFaultDatas(faultDatas);
    policyData.setJsonBody("{}");
    assertThat(responseString).contains("Select At least one Condition");
    List<Object> trap1 = new ArrayList<>();
    trapDatas.setTrap1(trap1);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Trigger Clear TimeOut is required");
    policyData.setClearTimeOut("AValidClearTimeout");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Trap Max Age is required");
    policyData.setTrapMaxAge("AValidTrapMaxAge");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    trapDatas.setTrap1(null);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    faultDatas.setTrap1(null);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select at least one D2");
    faultDatas.setTrap1(trap1);
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Fault Clear TimeOut is required when");
    policyData.setVerificationclearTimeOut("AValidVerificationClearTimeout");
    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();
    assertThat(responseString).contains("vPRO Actions is required");
    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();
    assertThat(responseString).contains("vPRO Actions is required");
    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();
    assertThat(responseString).contains("vPRO Actions is required");
    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();
    assertThat(responseString).contains("vPRO Actions is required");
    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();
    assertThat(responseString).contains("vPRO Actions is required");
    policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": null}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("vPRO Actions is required");
    policyData.setJsonBody("{\"trinity\": true, \"emailAddress\": \"\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("vPRO Actions is required");
    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();
    assertThat(responseString).contains("vPRO Actions is required");
    policyData.setJsonBody("{\"trinity\": true, \"actions\": null}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("vPRO Actions is required");
    policyData.setJsonBody("{\"trinity\": true, \"actions\": \"\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("vPRO Actions is required");
    policyData.setJsonBody("{\"trinity\": true, \"actions\": \"$$$%%%\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Policy Status is required");
    assertThat(responseString).contains("Vnf Type is required");
    policyData.setJsonBody("{\"trinity\": true, \"actions\": \"ValidActions\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Policy Status is required");
    policyData.setJsonBody("{\"trinity\": true, \"actions\": \"ValidActions\", \"closedLoopPolicyStatus\": null}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Policy Status is required");
    policyData.setJsonBody("{\"trinity\": true, \"actions\": \"ValidActions\", \"closedLoopPolicyStatus\": \"\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Policy Status is required");
    policyData.setJsonBody(
                    "{\"trinity\": true, \"actions\": \"ValidActions\", \"closedLoopPolicyStatus\": \"$$$%%%\"}");
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select At least one Condition");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\""
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select At least one Condition");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": null"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Select At least one Condition");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\""
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Aging Window is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"geoLink\": null"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Aging Window is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"geoLink\": \"\""
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Aging Window is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"geoLink\": \"%%%$$$\""
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("GeoLink</b>:<i>The Value in Required Field");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"geoLink\": \"AValidGeoLink\""
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Aging Window is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Time Interval is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1,"
                    + "\"timeInterval\": -1"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Number of Retries is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1,"
                    + "\"timeInterval\": -1,"
                    + "\"retrys\": -1"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("APP-C Timeout is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1,"
                    + "\"timeInterval\": -1,"
                    + "\"retrys\": -1,"
                    + "\"timeOutvPRO\": -1"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("TimeOutRuby is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1,"
                    + "\"timeInterval\": -1,"
                    + "\"retrys\": -1,"
                    + "\"timeOutvPRO\": -1,"
                    + "\"timeOutRuby\": -1"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Vnf Type is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1,"
                    + "\"timeInterval\": -1,"
                    + "\"retrys\": -1,"
                    + "\"timeOutvPRO\": -1,"
                    + "\"timeOutRuby\": -1,"
                    + "\"vnfType\": null"
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Vnf Type is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1,"
                    + "\"timeInterval\": -1,"
                    + "\"retrys\": -1,"
                    + "\"timeOutvPRO\": -1,"
                    + "\"timeOutRuby\": -1,"
                    + "\"vnfType\": \"\""
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertThat(responseString).contains("Vnf Type is required");
    // @formatter:off
    policyData.setJsonBody("{"
                    + "\"trinity\": true,"
                    + "\"actions\": \"ValidActions\","
                    + "\"closedLoopPolicyStatus\": \"AValidStatus\","
                    + "\"conditions\": \"SEND\","
                    + "\"agingWindow\": -1,"
                    + "\"timeInterval\": -1,"
                    + "\"retrys\": -1,"
                    + "\"timeOutvPRO\": -1,"
                    + "\"timeOutRuby\": -1,"
                    + "\"vnfType\": \"AValid VNF Type\""
                    + "}");
    // @formatter:on
    responseString = validation.validatePolicy(policyData).toString();
    assertEquals("success@#", responseString);
}