public ValidationErrorException(final String message, final Throwable e) { this(message, e, new ValidatorHelperResult(new ValidatorError(message))); result.getErrors().get(0).setException(e); }
/** * This method check if hasNonConfidentialIncorrectValues method can receive repeated values in the last 2 positions. */ public void testHasNonConfidentialIncorrectValues_RepeatedValuesInLastPosition() { String parameter = "param1"; String[] values = new String[] { "0", "10", "20", "20" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.REPEATED_VALUES_FOR_PARAMETER, actualResult.getErrors().get(0).getType()); }
/** * This method check if hasNonConfidentialIncorrectValues method can receive repeated values of received array values. */ public void testHasNonConfidentialIncorrectValues_RepeatedValuesInAnyPosition_2() { String parameter = "param1"; String[] values = new String[] { "20", "0", "20", "10" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.REPEATED_VALUES_FOR_PARAMETER, actualResult.getErrors().get(0).getType()); }
/** * This method check if hasNonConfidentialIncorrectValues method can receive repeated values in the middle of received array values. */ public void testHasNonConfidentialIncorrectValues_RepeatedValuesInTheMiddle() { String parameter = "param1"; String[] values = new String[] { "0", "20", "20", "10" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.REPEATED_VALUES_FOR_PARAMETER, actualResult.getErrors().get(0).getType()); }
/** * This method check if hasNonConfidentialIncorrectValues method can receive repeated values of received array values. */ public void testHasNonConfidentialIncorrectValues_RepeatedValuesInAnyPosition_1() { String parameter = "param1"; String[] values = new String[] { "20", "0", "10", "20" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.REPEATED_VALUES_FOR_PARAMETER, actualResult.getErrors().get(0).getType()); }
/** * This method check if hasNonConfidentialIncorrectValues method can receive repeated values of received array values. */ public void testHasNonConfidentialIncorrectValues_RepeatedValuesInAnyPosition_3() { String parameter = "param1"; String[] values = new String[] { "0", "20", "10", "20" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.REPEATED_VALUES_FOR_PARAMETER, actualResult.getErrors().get(0).getType()); }
/** * This method check that hasNonConfidentialIncorrectValues method returns invalid result when unexpected value is received for specific * parameter. */ public void testHasNonConfidentialIncorrectValues_IncorrectParameterValueReceivedInLastPosition() { String parameter = "param1"; String[] values = new String[] { "0", "10", "99999" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.INVALID_PARAMETER_VALUE, actualResult.getErrors().get(0).getType()); }
/** * This method check that hasNonConfidentialIncorrectValues method returns invalid result when unexpected value is received for specific * parameter. */ public void testHasNonConfidentialIncorrectValues_IncorrectParameterValueReceivedInTheMiddle() { String parameter = "param1"; String[] values = new String[] { "0", "99999", "10" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.INVALID_PARAMETER_VALUE, actualResult.getErrors().get(0).getType()); }
/** * This method check if hasNonConfidentialIncorrectValues method can receive repeated values at first positions of received array * values. */ public void testHasNonConfidentialIncorrectValues_RepeatedValuesAtFirstPositions() { String parameter = "param1"; String[] values = new String[] { "20", "20", "0", "10" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.REPEATED_VALUES_FOR_PARAMETER, actualResult.getErrors().get(0).getType()); }
/** * This method check that hasNonConfidentialIncorrectValues method returns invalid result when unexpected value is received for specific * parameter. */ public void testHasNonConfidentialIncorrectValues_IncorrectParameterValueReceivedAtFirstPosition() { String parameter = "param1"; String[] values = new String[] { "99999", "0", "10" }; List<String> tempStateValues = new ArrayList<String>(); tempStateValues.add("0"); tempStateValues.add("10"); tempStateValues.add("20"); ValidatorHelperResult actualResult = ((ValidatorHelperRequest) helper).hasNonConfidentialIncorrectValues(targetName, parameter, values, tempStateValues); assertFalse(actualResult.isValid()); assertEquals(HDIVErrorCodes.INVALID_PARAMETER_VALUE, actualResult.getErrors().get(0).getType()); } }
public void testEditableParameterValidation() { MockHttpServletRequest request = getMockRequest(); request.setMethod("POST"); dataComposer.beginRequest(Method.POST, targetName); dataComposer.compose("paramName", "", true, "text"); String pageState = dataComposer.endRequest(); dataComposer.endPage(); addParameter(pageState); request.addParameter("paramName", "<script>storeCookie()</script>"); ValidatorHelperResult result = helper.validate(context); assertFalse(result.isValid()); // Editable errors List<ValidatorError> errors = result.getErrors(); assertEquals(1, errors.size()); assertEquals(HDIVErrorCodes.INVALID_EDITABLE_VALUE, errors.get(0).getType()); }
public void testValidateEditableFieldsRequiredByDefault() { getConfig().setEditableFieldsRequiredByDefault(true); dataComposer.beginRequest(Method.GET, targetName); dataComposer.compose("text", "value1", true, "text"); String pageState = dataComposer.endRequest(); dataComposer.endPage(); addParameter(pageState); ValidatorHelperResult result = helper.validate(context); assertFalse(result.isValid()); assertEquals(HDIVErrorCodes.NOT_RECEIVED_ALL_REQUIRED_PARAMETERS, result.getErrors().get(0).getType()); getConfig().setEditableFieldsRequiredByDefault(false); }