
org.catools.common.extensions.verify.CDateVerification Maven / Gradle / Ivy
package org.catools.common.extensions.verify;
import org.catools.common.date.CDate;
import org.catools.common.extensions.verify.interfaces.CDateVerifier;
import org.catools.common.logger.CLogger;
import java.util.Date;
/**
* Date verification class contains all verification method which is related to Date
*
* @param represent any classes which extent {@link CVerificationBuilder}.
*/
public class CDateVerification extends CBaseVerification {
public CDateVerification(T verifier, CLogger logger) {
super(verifier, logger);
}
/**
* Verify that actual and expected have the exact same date value (compare to milliseconds) or they both has null value
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equals(final Date actual, final Date expected, final String message, final Object... params) {
return toVerifier(actual).verifyEquals(verifier, expected, message, params);
}
/**
* Verify that actual and expected have the exact same date value (compare to milliseconds) or they both has null value
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equals(final Date actual, final Date expected, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyEquals(verifier, expected, waitInSeconds, message, params);
}
/**
* Verify that actual and expected have the exact same date value (compare to milliseconds) or they both has null value
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param intervalInMilliSeconds interval between retries in milliseconds
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equals(final Date actual, final Date expected, final int waitInSeconds, final int intervalInMilliSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyEquals(verifier, expected, waitInSeconds, intervalInMilliSeconds, message, params);
}
/**
* Verify that actual and expected have the exact same string value after they converted using the provided date format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" using "yyyy-MM-dd" passes.
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param format date format to be use
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsByFormat(final Date actual, final Date expected, final String format, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsByFormat(verifier, expected, format, message, params);
}
/**
* Verify that actual and expected have the exact same string value after they converted using the provided date format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" using "yyyy-MM-dd" passes.
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param format date format to be use
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsByFormat(final Date actual, final Date expected, final String format, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsByFormat(verifier, expected, format, waitInSeconds, message, params);
}
/**
* Verify that actual and expected have the exact same string value after they converted using the provided date format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" using "yyyy-MM-dd" passes.
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param format date format to be use
* @param waitInSeconds maximum wait time
* @param intervalInMilliSeconds interval between retries in milliseconds
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsByFormat(final Date actual,
final Date expected,
final String format,
final int waitInSeconds,
final int intervalInMilliSeconds,
final String message,
final Object... params) {
return toVerifier(actual).verifyEqualsByFormat(verifier, expected, format, waitInSeconds, intervalInMilliSeconds, message, params);
}
/**
* Verify that actual and expected have same string value after they converted using "yyyy-MM-dd" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" passes
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsDatePortion(final Date actual, final Date expected, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsDatePortion(verifier, expected, message, params);
}
/**
* Verify that actual and expected have same string value after they converted using "yyyy-MM-dd" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" passes
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsDatePortion(final Date actual, final Date expected, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsDatePortion(verifier, expected, waitInSeconds, message, params);
}
/**
* Verify that actual and expected have same string value after they converted using "yyyy-MM-dd" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" passes
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param intervalInMilliSeconds interval between retries in milliseconds
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsDatePortion(final Date actual, final Date expected, final int waitInSeconds, final int intervalInMilliSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsDatePortion(verifier, expected, waitInSeconds, intervalInMilliSeconds, message, params);
}
/**
* Verify that actual and expected have same string value after they converted using "HH:mm:ss" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-08 12:20" passes
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsTimePortion(final Date actual, final Date expected, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsTimePortion(verifier, expected, message, params);
}
/**
* Verify that actual and expected have same string value after they converted using "HH:mm:ss" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-08 12:20" passes
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsTimePortion(final Date actual, final Date expected, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsTimePortion(verifier, expected, waitInSeconds, message, params);
}
/**
* Verify that actual and expected have same string value after they converted using "HH:mm:ss" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-08 12:20" passes
* Please note that verification consider as passe if both value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param intervalInMilliSeconds interval between retries in milliseconds
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T equalsTimePortion(final Date actual, final Date expected, final int waitInSeconds, final int intervalInMilliSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyEqualsTimePortion(verifier, expected, waitInSeconds, intervalInMilliSeconds, message, params);
}
/**
* Verify that actual and expected does not have the exact same date value (compare to milliseconds) or one of them is null
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEquals(final Date actual, final Date expected, final String message, final Object... params) {
return toVerifier(actual).verifyNotEquals(verifier, expected, message, params);
}
/**
* Verify that actual and expected does not have the exact same date value (compare to milliseconds) or one of them is null
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEquals(final Date actual, final Date expected, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyNotEquals(verifier, expected, waitInSeconds, message, params);
}
/**
* Verify that actual and expected does not have the exact same date value (compare to milliseconds) or one of them is null
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param intervalInMilliSeconds interval between retries in milliseconds
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEquals(final Date actual, final Date expected, final int waitInSeconds, final int intervalInMilliSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyNotEquals(verifier, expected, waitInSeconds, intervalInMilliSeconds, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using the provided date format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" using "yyyy-MM-dd HH" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param format date format to be use
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsByFormat(final Date actual, final Date expected, final String format, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsByFormat(verifier, expected, format, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using the provided date format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" using "yyyy-MM-dd HH" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param format date format to be use
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsByFormat(final Date actual, final Date expected, final String format, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsByFormat(verifier, expected, format, waitInSeconds, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using the provided date format.
* Means that verification of "2019-08-09 12:20" and "2019-08-09 11:20" using "yyyy-MM-dd HH" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param format date format to be use
* @param waitInSeconds maximum wait time
* @param intervalInMilliSeconds interval between retries in milliseconds
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsByFormat(final Date actual,
final Date expected,
final String format,
final int waitInSeconds,
final int intervalInMilliSeconds,
final String message,
final Object... params) {
return toVerifier(actual).verifyNotEqualsByFormat(verifier, expected, format, waitInSeconds, intervalInMilliSeconds, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using "yyyy-MM-dd" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-08 12:20" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsDatePortion(final Date actual, final Date expected, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsDatePortion(verifier, expected, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using "yyyy-MM-dd" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-08 12:20" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsDatePortion(final Date actual, final Date expected, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsDatePortion(verifier, expected, waitInSeconds, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using "yyyy-MM-dd" for format.
* Means that verification of "2019-08-09 12:20" and "2019-08-08 12:20" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsDatePortion(final Date actual, final Date expected, final int waitInSeconds, final int intervalInMilliSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsDatePortion(verifier, expected, waitInSeconds, intervalInMilliSeconds, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using "HH:mm:ss" for format.
* Means that verification of "2019-08-09 12:20:31" and "2019-08-09 12:20:30" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsTimePortion(final Date actual, final Date expected, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsTimePortion(verifier, expected, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using "HH:mm:ss" for format.
* Means that verification of "2019-08-09 12:20:31" and "2019-08-09 12:20:30" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsTimePortion(final Date actual, final Date expected, final int waitInSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsTimePortion(verifier, expected, waitInSeconds, message, params);
}
/**
* Verify that actual and expected have different string value after they converted using "HH:mm:ss" for format.
* Means that verification of "2019-08-09 12:20:31" and "2019-08-09 12:20:30" passes (means values are different)
* Please note that verification consider as passe if one of value is null
*
* @param actual value to compare
* @param expected value to compare
* @param waitInSeconds maximum wait time
* @param intervalInMilliSeconds interval between retries in milliseconds
* @param message information about the propose of this verification
* @param params parameters in case if message is a format {@link String#format}
* @return caller {@link CVerificationBuilder} so we can do chain calls
*/
public T notEqualsTimePortion(final Date actual, final Date expected, final int waitInSeconds, final int intervalInMilliSeconds, final String message, final Object... params) {
return toVerifier(actual).verifyNotEqualsTimePortion(verifier, expected, waitInSeconds, intervalInMilliSeconds, message, params);
}
private CDateVerifier toVerifier(Date actual) {
return () -> actual == null ? null : new CDate(actual);
}
}