Package org.hibernate.validator.test.internal.constraintvalidators.bv.past

Source Code of org.hibernate.validator.test.internal.constraintvalidators.bv.past.PastValidatorForInstantTest

/*
* Hibernate Validator, declare and validate application constraints
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.test.internal.constraintvalidators.bv.past;

import java.time.Instant;

import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import org.hibernate.validator.internal.constraintvalidators.bv.past.PastValidatorForInstant;

import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

/**
* Tests for {@link org.hibernate.validator.internal.constraintvalidators.bv.past.PastValidatorForInstant}.
*
* @author Khalid Alqinyah
*/
public class PastValidatorForInstantTest {

  private PastValidatorForInstant constraint;

  @BeforeClass
  public void init() {
    constraint = new PastValidatorForInstant();
  }

  @Test
  public void testIsValid() {
    Instant future = Instant.now().plusSeconds( 3600 );
    Instant past = Instant.now().minusSeconds( 3600 );

    assertTrue( constraint.isValid( null, null ), "null fails validation." );
    assertTrue( constraint.isValid( past, null ), "Past Instant '" + past + "' fails validation.");
    assertFalse( constraint.isValid( future, null ), "Future Instant '" + future + "' validated as past.");
  }
}
TOP

Related Classes of org.hibernate.validator.test.internal.constraintvalidators.bv.past.PastValidatorForInstantTest

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.