Package org.crank.validation.readers

Source Code of org.crank.validation.readers.AnnotationValidatorMetaDataReaderTest

package org.crank.validation.readers;

import java.util.List;

import org.crank.validation.ValidatorMetaData;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.*;

public class AnnotationValidatorMetaDataReaderTest {

  private AnnotationValidatorMetaDataReader annotationValidatorMetaDataReader;
  @BeforeMethod
  protected void setUp() throws Exception {
    annotationValidatorMetaDataReader = new AnnotationValidatorMetaDataReader();
  }

  @AfterMethod
  protected void tearDown() throws Exception {
  }

  @Test()
  public void testReadMetaData() {
    List<ValidatorMetaData> list = annotationValidatorMetaDataReader.readMetaData(Employee.class, "age");
    assertNotNull(list);
    ValidatorMetaData required = list.get(0);
    assertEquals("required", required.getName());
    ValidatorMetaData range = list.get(1);
    assertEquals("range", range.getName());
    assertEquals("10",range.getProperties().get("max"));
    assertEquals("1",range.getProperties().get("min"));
   
  }

  @Test
  public void testReadMetaDataWithNonStringValues() {
    List<ValidatorMetaData> list =
      annotationValidatorMetaDataReader.readMetaData(Employee.class, "iq");
    assertNotNull(list);
    assertEquals(2, list.size());
    ValidatorMetaData range = list.get(1);
    assertEquals("longRange", range.getName());
    assertEquals(100L,range.getProperties().get("max"));
    assertEquals(1L,range.getProperties().get("min"));
   
  }

   
}

TOP

Related Classes of org.crank.validation.readers.AnnotationValidatorMetaDataReaderTest

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.