Examples of DictionaryValidationResult


Examples of org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult

    //String date = "28 Feb 2013 03:50 PM";
    Timestamp date = new Timestamp(System.currentTimeMillis());
    SingleAttributeValueReader attributeValueReader = new SingleAttributeValueReader(
        date, MatterEvent.class.getCanonicalName(), attributeName,
        dateDefinition);
    DictionaryValidationResult dictionaryValidationResult = new DictionaryValidationResult();
    dictionaryValidationResult.setErrorLevel(ErrorLevel.NOCONSTRAINT);

    ValidCharactersConstraintProcessor processor = new ValidCharactersConstraintProcessor();
    // setup mocks
    Config config = mock(Config.class);
    final String dtFormat = "dd MMM yyyy hh:mm a";
    when(config.getProperty(CoreConstants.STRING_TO_DATE_FORMATS))
        .thenReturn(dtFormat);
    ConfigContext.overrideConfig(Thread.currentThread()
        .getContextClassLoader(), config);
    DateTimeService dtSvc = mock(DateTimeService.class);
    SimpleDateFormat sdf = new SimpleDateFormat(dtFormat);
    when(dtSvc.toDateTimeString(date)).thenReturn(sdf.format(date));
    attributeValueReader.setDateTimeService(dtSvc);
    // create allowed formats
    List<String> allowedFormats = new ArrayList<String>();
    allowedFormats.add(dtFormat);
    allowedFormats.add("d MMM yyyy hh:mm a");
    allowedFormats.add("dd MMM yyyy");
    allowedFormats.add("d MMM yyyy");
    // carry out validation
    DatePatternConstraint constraint = new DatePatternConstraint();
    constraint.setAllowedFormats(allowedFormats);
    ConstraintValidationResult result = processor.process(
        dictionaryValidationResult, date, constraint,
        attributeValueReader).getFirstConstraintValidationResult();
    // assertions
    log.info(ToStringBuilder.reflectionToString(dictionaryValidationResult));
    assertEquals("number of warnings differs", 0,
        dictionaryValidationResult.getNumberOfWarnings());
    assertEquals("number of errors differs", 0,
        dictionaryValidationResult.getNumberOfErrors());
    assertEquals("error level differs", ErrorLevel.OK, result.getStatus());
    assertEquals("constraint name differs",
        new ValidCharactersConstraintProcessor().getName(),
        result.getConstraintName());
  }
View Full Code Here

Examples of org.kuali.rice.krad.datadictionary.validation.result.DictionaryValidationResult

   * @param expectedErrors
   * @param attributeName
   */
  public void validate(Object bo, final int expectedErrors, final String attributeName) {
    try {
      DictionaryValidationResult result = KRADServiceLocatorWeb.getDictionaryValidationService().validate(bo,
          bo.getClass().getCanonicalName(), attributeName, true);
      final Iterator<ConstraintValidationResult> iterator = result.iterator();
      while (iterator.hasNext()) {
        final ConstraintValidationResult validationResult = iterator.next();
        // using error level to avoid having to configure logging
        log.error(ReflectionToStringBuilder.toString(validationResult));
      }
      assertEquals("expected number of errors differ", expectedErrors, result.getNumberOfErrors());
    } catch (Exception e) {
      log.error("exception occured", e);
      fail("exception occured");
    }
  }
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.