Package jodd.vtor

Source Code of jodd.vtor.AnnotationTest

// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.

package jodd.vtor;

import jodd.vtor.constraint.TimeAfterConstraint;
import jodd.vtor.data.Tad;
import jodd.vtor.data.Woo;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class AnnotationTest {

  @Test
  public void testAnn() {
    Vtor vtor = new Vtor();
    vtor.validate(new Woo());
    List<Violation> v = vtor.getViolations();
    assertEquals(1, v.size());

    vtor.resetViolations();
    vtor.useProfiles("p1", "p2");
    vtor.validate(new Woo());
    v = vtor.getViolations();
    assertEquals(2, v.size());

    vtor.resetViolations();
    vtor.useProfiles("default", "p1", "p2");
    vtor.validate(new Woo());
    v = vtor.getViolations();
    assertEquals(3, v.size());
  }

  @Test
  public void testTime() {
    Vtor vtor = new Vtor();
    vtor.validate(new Tad());

    assertTrue(vtor.hasViolations());
    List<Violation> v = vtor.getViolations();

    assertEquals(3, v.size());

    assertEquals(TimeAfterConstraint.class, v.get(0).getConstraint().getClass());
  }
}
TOP

Related Classes of jodd.vtor.AnnotationTest

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.