| 1 | package ezvcard.property.asserter; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | |
| 5 | import java.time.temporal.Temporal; |
| 6 | import java.util.List; |
| 7 | |
| 8 | import ezvcard.property.DateOrTimeProperty; |
| 9 | import ezvcard.util.PartialDate; |
| 10 | |
| 11 | /* |
| 12 | Copyright (c) 2012-2023, Michael Angstadt |
| 13 | All rights reserved. |
| 14 | |
| 15 | Redistribution and use in source and binary forms, with or without |
| 16 | modification, are permitted provided that the following conditions are met: |
| 17 | |
| 18 | 1. Redistributions of source code must retain the above copyright notice, this |
| 19 | list of conditions and the following disclaimer. |
| 20 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 21 | this list of conditions and the following disclaimer in the documentation |
| 22 | and/or other materials provided with the distribution. |
| 23 | |
| 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 25 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 28 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 31 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | |
| 35 | The views and conclusions contained in the software and documentation are those |
| 36 | of the authors and should not be interpreted as representing official policies, |
| 37 | either expressed or implied, of the FreeBSD Project. |
| 38 | */ |
| 39 | |
| 40 | /** |
| 41 | * @author Michael Angstadt |
| 42 | */ |
| 43 | public class DateOrTimePropertyAsserter<T extends DateOrTimeProperty> extends PropertyAsserter<DateOrTimePropertyAsserter<T>, T> { |
| 44 | private Temporal date; |
| 45 | private PartialDate partialDate; |
| 46 | private String text; |
| 47 | |
| 48 | public DateOrTimePropertyAsserter(List<T> properties, VCardAsserter asserter) { |
| 49 | super(properties, asserter); |
| 50 | } |
| 51 | |
| 52 | public DateOrTimePropertyAsserter<T> date(Temporal date) { |
| 53 | this.date = date; |
| 54 | return this_; |
| 55 | } |
| 56 | |
| 57 | public DateOrTimePropertyAsserter<T> partialDate(PartialDate partialDate) { |
| 58 | this.partialDate = partialDate; |
| 59 | return this_; |
| 60 | } |
| 61 | |
| 62 | public DateOrTimePropertyAsserter<T> text(String text) { |
| 63 | this.text = text; |
| 64 | return this_; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | protected void _run(T property) { |
| 69 | assertEquals(date, property.getDate()); |
| 70 | assertEquals(partialDate, property.getPartialDate()); |
| 71 | assertEquals(text, property.getText()); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | protected void _reset() { |
| 76 | date = null; |
| 77 | partialDate = null; |
| 78 | text = null; |
| 79 | } |
| 80 | } |