001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bct.assertions; 018 019import java.io.*; 020import java.time.temporal.*; 021import java.util.*; 022import java.util.function.*; 023 024 025/** 026 * Used for assertion calls against {@link Date} objects. 027 * 028 * <h2 class='section'>Example:</h2> 029 * <p class='bjava'> 030 * <jc>// Validates the specified date is after the current date.</jc> 031 * <jsm>assertDate</jsm>(<jv>myDate</jv>).isAfterNow(); 032 * </p> 033 * 034 * <h2 class='section'>Test Methods:</h2> 035 * <ul class='javatree'> 036 * <li class='jc'>{@link FluentDateAssertion} 037 * <ul class='javatreec'> 038 * <li class='jm'>{@link FluentDateAssertion#is(Date,ChronoUnit) is(Date,ChronoUnit)} 039 * <li class='jm'>{@link FluentDateAssertion#isAfter(Date) isAfter(Date)} 040 * <li class='jm'>{@link FluentDateAssertion#isAfterNow() isAfterNow()} 041 * <li class='jm'>{@link FluentDateAssertion#isBefore(Date) isBefore(Date)} 042 * <li class='jm'>{@link FluentDateAssertion#isBeforeNow() isBeforeNow()} 043 * <li class='jm'>{@link FluentDateAssertion#isBetween(Date,Date) isBetween(Date,Date)} 044 * </ul> 045 * <li class='jc'>{@link FluentComparableAssertion} 046 * <ul class='javatreec'> 047 * <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)} 048 * <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)} 049 * <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)} 050 * <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)} 051 * <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)} 052 * </ul> 053 * <li class='jc'>{@link FluentObjectAssertion} 054 * <ul class='javatreec'> 055 * <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()} 056 * <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)} 057 * <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)} 058 * <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)} 059 * <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} 060 * <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} 061 * <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()} 062 * <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()} 063 * <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)} 064 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 065 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 066 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 067 * </ul> 068 * </ul> 069 * 070 * <h2 class='section'>Transform Methods:</h2> 071 * <ul class='javatree'> 072 * <li class='jc'>{@link FluentDateAssertion} 073 * <ul class='javatreec'> 074 * <li class='jm'>{@link FluentDateAssertion#asEpochMillis() asEpochMillis()} 075 * <li class='jm'>{@link FluentDateAssertion#asEpochSeconds() asEpochSeconds()} 076 * </ul> 077 * <li class='jc'>{@link FluentObjectAssertion} 078 * <ul class='javatreec'> 079 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 080 * <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)} 081 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)} 082 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 083 * </ul> 084 * </ul> 085 * 086 * <h2 class='section'>Configuration Methods:</h2> 087 * <ul class='javatree'> 088 * <li class='jc'>{@link Assertion} 089 * <ul class='javatreec'> 090 * <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} 091 * <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)} 092 * <li class='jm'>{@link Assertion#setSilent() setSilent()} 093 * <li class='jm'>{@link Assertion#setStdOut() setStdOut()} 094 * <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)} 095 * </ul> 096 * </ul> 097 * 098 * <h2 class='section'>See Also:</h2><ul> 099 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a> 100 * </ul> 101 */ 102@SuppressWarnings({ 103 "java:S110" // Inheritance depth acceptable for DateAssertion hierarchy 104}) 105public class DateAssertion extends FluentDateAssertion<DateAssertion> { 106 107 /** 108 * Static creator. 109 * 110 * @param value 111 * The object being tested. 112 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 113 * @return A new assertion object. 114 */ 115 public static DateAssertion create(Date value) { 116 return new DateAssertion(value); 117 } 118 119 /** 120 * Constructor. 121 * 122 * @param value 123 * The object being tested. 124 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 125 */ 126 public DateAssertion(Date value) { 127 super(value, null); 128 } 129 130 @Override /* Overridden from Assertion */ 131 public DateAssertion setMsg(String msg, Object...args) { 132 super.setMsg(msg, args); 133 return this; 134 } 135 136 @Override /* Overridden from Assertion */ 137 public DateAssertion setOut(PrintStream value) { 138 super.setOut(value); 139 return this; 140 } 141 142 @Override /* Overridden from Assertion */ 143 public DateAssertion setSilent() { 144 super.setSilent(); 145 return this; 146 } 147 148 @Override /* Overridden from Assertion */ 149 public DateAssertion setStdOut() { 150 super.setStdOut(); 151 return this; 152 } 153 154 @Override /* Overridden from Assertion */ 155 public DateAssertion setThrowable(Class<? extends RuntimeException> value) { 156 super.setThrowable(value); 157 return this; 158 } 159}