ru.d_shap.assertions.Assertions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertions Show documentation
Show all versions of assertions Show documentation
Assertions library provides facilities for the unit testing
///////////////////////////////////////////////////////////////////////////////////////////////////
// Assertions library provides facilities for the unit testing.
// Copyright (C) 2017 Dmitry Shapovalov.
//
// This file is part of assertions library.
//
// Assertions library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Assertions library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see .
///////////////////////////////////////////////////////////////////////////////////////////////////
package ru.d_shap.assertions;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.Reader;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TimeZone;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import org.hamcrest.Matcher;
import org.w3c.dom.Attr;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import ru.d_shap.assertions.asimp.array.BooleanArrayAssertion;
import ru.d_shap.assertions.asimp.array.ByteArrayAssertion;
import ru.d_shap.assertions.asimp.array.CharArrayAssertion;
import ru.d_shap.assertions.asimp.array.DoubleArrayAssertion;
import ru.d_shap.assertions.asimp.array.FloatArrayAssertion;
import ru.d_shap.assertions.asimp.array.IntArrayAssertion;
import ru.d_shap.assertions.asimp.array.LongArrayAssertion;
import ru.d_shap.assertions.asimp.array.ObjectArrayAssertion;
import ru.d_shap.assertions.asimp.array.ShortArrayAssertion;
import ru.d_shap.assertions.asimp.java.io.BufferedReaderAssertion;
import ru.d_shap.assertions.asimp.java.io.InputStreamAssertion;
import ru.d_shap.assertions.asimp.java.io.ReaderAssertion;
import ru.d_shap.assertions.asimp.java.lang.CharSequenceAssertion;
import ru.d_shap.assertions.asimp.java.lang.ClassAssertion;
import ru.d_shap.assertions.asimp.java.lang.ComparableAssertion;
import ru.d_shap.assertions.asimp.java.lang.IterableAssertion;
import ru.d_shap.assertions.asimp.java.lang.ObjectAssertion;
import ru.d_shap.assertions.asimp.java.lang.ThrowableAssertion;
import ru.d_shap.assertions.asimp.java.nio.ByteBufferAssertion;
import ru.d_shap.assertions.asimp.java.nio.CharBufferAssertion;
import ru.d_shap.assertions.asimp.java.nio.DoubleBufferAssertion;
import ru.d_shap.assertions.asimp.java.nio.FloatBufferAssertion;
import ru.d_shap.assertions.asimp.java.nio.IntBufferAssertion;
import ru.d_shap.assertions.asimp.java.nio.LongBufferAssertion;
import ru.d_shap.assertions.asimp.java.nio.ShortBufferAssertion;
import ru.d_shap.assertions.asimp.java.util.CalendarAssertion;
import ru.d_shap.assertions.asimp.java.util.DateAssertion;
import ru.d_shap.assertions.asimp.java.util.IteratorAssertion;
import ru.d_shap.assertions.asimp.java.util.ListAssertion;
import ru.d_shap.assertions.asimp.java.util.LocaleAssertion;
import ru.d_shap.assertions.asimp.java.util.MapAssertion;
import ru.d_shap.assertions.asimp.java.util.SetAssertion;
import ru.d_shap.assertions.asimp.java.util.SortedMapAssertion;
import ru.d_shap.assertions.asimp.java.util.SortedSetAssertion;
import ru.d_shap.assertions.asimp.java.util.TimeZoneAssertion;
import ru.d_shap.assertions.asimp.javax.xml.datatype.XMLGregorianCalendarAssertion;
import ru.d_shap.assertions.asimp.javax.xml.namespace.QNameAssertion;
import ru.d_shap.assertions.asimp.org.w3c.dom.AttrAssertion;
import ru.d_shap.assertions.asimp.org.w3c.dom.CharacterDataAssertion;
import ru.d_shap.assertions.asimp.org.w3c.dom.DocumentAssertion;
import ru.d_shap.assertions.asimp.org.w3c.dom.ElementAssertion;
import ru.d_shap.assertions.asimp.org.w3c.dom.NodeAssertion;
import ru.d_shap.assertions.asimp.primitive.BooleanAssertion;
import ru.d_shap.assertions.asimp.primitive.ByteAssertion;
import ru.d_shap.assertions.asimp.primitive.CharAssertion;
import ru.d_shap.assertions.asimp.primitive.DoubleAssertion;
import ru.d_shap.assertions.asimp.primitive.FloatAssertion;
import ru.d_shap.assertions.asimp.primitive.IntAssertion;
import ru.d_shap.assertions.asimp.primitive.LongAssertion;
import ru.d_shap.assertions.asimp.primitive.ShortAssertion;
import ru.d_shap.assertions.fail.AssertionErrorBuilder;
/**
* Entry point of all assertions.
*
* @author Dmitry Shapovalov
*/
public final class Assertions {
private Assertions() {
super();
}
/**
* Make assertion with the assertion message.
*
* @param message the assertion message.
*
* @return the assertion.
*/
public static MessageAssertion assertWithMessage(final String message) {
return new MessageAssertion(message);
}
/**
* Make assertion about the byte.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static ByteAssertion assertThat(final byte actual) {
ByteAssertion assertion = Raw.byteAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the byte.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static ByteAssertion assertThat(final Byte actual) {
ByteAssertion assertion = Raw.byteAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the short.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static ShortAssertion assertThat(final short actual) {
ShortAssertion assertion = Raw.shortAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the short.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static ShortAssertion assertThat(final Short actual) {
ShortAssertion assertion = Raw.shortAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the int.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static IntAssertion assertThat(final int actual) {
IntAssertion assertion = Raw.intAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the int.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static IntAssertion assertThat(final Integer actual) {
IntAssertion assertion = Raw.intAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the long.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static LongAssertion assertThat(final long actual) {
LongAssertion assertion = Raw.longAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the long.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static LongAssertion assertThat(final Long actual) {
LongAssertion assertion = Raw.longAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the float.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static FloatAssertion assertThat(final float actual) {
FloatAssertion assertion = Raw.floatAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the float.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static FloatAssertion assertThat(final Float actual) {
FloatAssertion assertion = Raw.floatAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the double.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static DoubleAssertion assertThat(final double actual) {
DoubleAssertion assertion = Raw.doubleAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the double.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static DoubleAssertion assertThat(final Double actual) {
DoubleAssertion assertion = Raw.doubleAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the boolean.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static BooleanAssertion assertThat(final boolean actual) {
BooleanAssertion assertion = Raw.booleanAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the boolean.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static BooleanAssertion assertThat(final Boolean actual) {
BooleanAssertion assertion = Raw.booleanAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the char.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static CharAssertion assertThat(final char actual) {
CharAssertion assertion = Raw.charAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the char.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static CharAssertion assertThat(final Character actual) {
CharAssertion assertion = Raw.charAssertion();
((BaseAssertion) assertion).initialize(actual);
return assertion;
}
/**
* Make assertion about the object.
*
* @param actual the actual value.
*
* @return the assertion.
*/
public static ObjectAssertion assertThat(final Object actual) {
ObjectAssertion assertion = Raw.objectAssertion();
((BaseAssertion