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