Package org.springframework.validation

Examples of org.springframework.validation.BeanPropertyBindingResult.addError()


    }

    @Test
    public void invalidForumInformationShouldProduceFailResponse() {
        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        bindingResult.addError(new ObjectError("name", "message"));
        JsonResponse response = administrationController.setForumInformation(new ComponentInformation(), bindingResult,
                Locale.UK);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }
View Full Code Here


    }

    @Test
    public void invalidBranchInformationShouldProduceFailResponse() throws NotFoundException {
        BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(new Object(), "");
        bindingResult.addError(new ObjectError("name", "message"));
        BranchDto branchDto = new BranchDto();
        JsonResponse response = administrationController.setBranchInformation(branchDto, bindingResult, Locale.UK);

        assertEquals(response.getStatus(), JsonResponseStatus.FAIL);
    }
View Full Code Here

    @Test
    public void testRestorePasswordWrongMail() throws Exception {
        RestorePasswordDto dto = new RestorePasswordDto();
        dto.setUserEmail(EMAIL);
        BindingResult bindingResult = new BeanPropertyBindingResult(dto, "email");
        bindingResult.addError(new FieldError("", "", ""));
        ModelAndView mav = userController.restorePassword(dto, bindingResult);
        verifyZeroInteractions(userService);
        assertViewName(mav, "restorePassword");
    }
View Full Code Here

    Object payload = message.getPayload();
    if (isEmptyPayload(payload)) {
      if (annot == null || annot.required()) {
        String paramName = getParameterName(param);
        BindingResult bindingResult = new BeanPropertyBindingResult(payload, paramName);
        bindingResult.addError(new ObjectError(paramName, "@Payload param is required"));
        throw new MethodArgumentNotValidException(message, param, bindingResult);
      }
      else {
        return null;
      }
View Full Code Here


    for (String key : raw.keySet()) {
      int separator = key.indexOf(OPTION_SEPARATOR);
      if (separator == -1) {
        bindingResult.addError(new FieldError("options", key, String.format("unsupported option '%s'", key)));
        continue;
      }
      String prefix = key.substring(0, separator);
      String suffix = key.substring(separator + OPTION_SEPARATOR.length());
      Map<String, String> map = valuesWithoutPrefix.get(prefix);
View Full Code Here

      }
      String prefix = key.substring(0, separator);
      String suffix = key.substring(separator + OPTION_SEPARATOR.length());
      Map<String, String> map = valuesWithoutPrefix.get(prefix);
      if (map == null) {
        bindingResult.addError(new FieldError("options", key, String.format("unsupported option '%s'", key)));
        continue;
      }
      map.put(suffix, raw.get(key));
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.