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 * <h5 class='section'>Example:</h5> 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 * <h5 class='section'>Test Methods:</h5> 035 * <p> 036 * <ul class='javatree'> 037 * <li class='jc'>{@link FluentDateAssertion} 038 * <ul class='javatreec'> 039 * <li class='jm'>{@link FluentDateAssertion#is(Date,ChronoUnit) is(Date,ChronoUnit)} 040 * <li class='jm'>{@link FluentDateAssertion#isAfter(Date) isAfter(Date)} 041 * <li class='jm'>{@link FluentDateAssertion#isAfterNow() isAfterNow()} 042 * <li class='jm'>{@link FluentDateAssertion#isBefore(Date) isBefore(Date)} 043 * <li class='jm'>{@link FluentDateAssertion#isBeforeNow() isBeforeNow()} 044 * <li class='jm'>{@link FluentDateAssertion#isBetween(Date,Date) isBetween(Date,Date)} 045 * </ul> 046 * <li class='jc'>{@link FluentComparableAssertion} 047 * <ul class='javatreec'> 048 * <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)} 049 * <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)} 050 * <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)} 051 * <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)} 052 * <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)} 053 * </ul> 054 * <li class='jc'>{@link FluentObjectAssertion} 055 * <ul class='javatreec'> 056 * <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()} 057 * <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)} 058 * <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)} 059 * <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)} 060 * <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} 061 * <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} 062 * <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()} 063 * <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()} 064 * <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)} 065 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 066 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 067 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 068 * </ul> 069 * </ul> 070 * 071 * <h5 class='section'>Transform Methods:</h5> 072 * <p> 073 * <ul class='javatree'> 074 * <li class='jc'>{@link FluentDateAssertion} 075 * <ul class='javatreec'> 076 * <li class='jm'>{@link FluentDateAssertion#asEpochMillis() asEpochMillis()} 077 * <li class='jm'>{@link FluentDateAssertion#asEpochSeconds() asEpochSeconds()} 078 * </ul> 079 * <li class='jc'>{@link FluentObjectAssertion} 080 * <ul class='javatreec'> 081 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 082 * <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)} 083 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)} 084 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 085 * </ul> 086 * </ul> 087 * 088 * <h5 class='section'>Configuration Methods:</h5> 089 * <p> 090 * <ul class='javatree'> 091 * <li class='jc'>{@link Assertion} 092 * <ul class='javatreec'> 093 * <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} 094 * <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)} 095 * <li class='jm'>{@link Assertion#setSilent() setSilent()} 096 * <li class='jm'>{@link Assertion#setStdOut() setStdOut()} 097 * <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)} 098 * </ul> 099 * </ul> 100 * 101 * <h5 class='section'>See Also:</h5><ul> 102 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a> 103 * </ul> 104 */ 105@SuppressWarnings({ 106 "java:S110" // Inheritance depth acceptable for DateAssertion hierarchy 107}) 108public class DateAssertion extends FluentDateAssertion<DateAssertion> { 109 110 /** 111 * Static creator. 112 * 113 * @param value 114 * The object being tested. 115 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 116 * @return A new assertion object. 117 */ 118 public static DateAssertion create(Date value) { 119 return new DateAssertion(value); 120 } 121 122 /** 123 * Constructor. 124 * 125 * @param value 126 * The object being tested. 127 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 128 */ 129 public DateAssertion(Date value) { 130 super(value, null); 131 } 132 133 @Override /* Overridden from Assertion */ 134 public DateAssertion setMsg(String msg, Object...args) { 135 super.setMsg(msg, args); 136 return this; 137 } 138 139 @Override /* Overridden from Assertion */ 140 public DateAssertion setOut(PrintStream value) { 141 super.setOut(value); 142 return this; 143 } 144 145 @Override /* Overridden from Assertion */ 146 public DateAssertion setSilent() { 147 super.setSilent(); 148 return this; 149 } 150 151 @Override /* Overridden from Assertion */ 152 public DateAssertion setStdOut() { 153 super.setStdOut(); 154 return this; 155 } 156 157 @Override /* Overridden from Assertion */ 158 public DateAssertion setThrowable(Class<? extends RuntimeException> value) { 159 super.setThrowable(value); 160 return this; 161 } 162}