/** * Check that the {@link java.time.OffsetTime} string representation to compare actual {@link java.time.OffsetTime} to * is not null, * otherwise throws a {@link IllegalArgumentException} with an explicit message * * @param OffsetTimeAsString String representing the {@link java.time.OffsetTime} to compare actual with * @throws IllegalArgumentException with an explicit message if the given {@link String} is null */ private static void assertOffsetTimeAsStringParameterIsNotNull(String OffsetTimeAsString) { checkArgument(OffsetTimeAsString != null, "The String representing the OffsetTime to compare actual with should not be null"); }
/** * Check that the {@link java.time.OffsetDateTime} to compare actual {@link java.time.OffsetDateTime} to is not null, * in that case throws a {@link IllegalArgumentException} with an explicit message * * @param other the {@link java.time.OffsetDateTime} to check * @throws IllegalArgumentException with an explicit message if the given {@link java.time.OffsetDateTime} is null */ private static void assertOffsetDateTimeParameterIsNotNull(OffsetDateTime other) { checkArgument(other != null, "The OffsetDateTime to compare actual with should not be null"); }
/** * Check that the {@link LocalDateTime} to compare actual {@link LocalDateTime} to is not null, in that case throws a * {@link IllegalArgumentException} with an explicit message * * @param other the {@link LocalDateTime} to check * @throws IllegalArgumentException with an explicit message if the given {@link LocalDateTime} is null */ private static void assertLocalDateTimeParameterIsNotNull(LocalDateTime other) { checkArgument(other != null, "The LocalDateTime to compare actual with should not be null"); }
/** * Verifies that the given {@link FilterOperator} reference is not {@code null}. * * @param <T> the type of the FilterOperator to check. * @param filterOperator the given {@link FilterOperator} reference. * @throws IllegalArgumentException if the given {@link FilterOperator} reference is {@code null}. */ public static <T> void checkNotNull(FilterOperator<T> filterOperator) { checkArgument(filterOperator != null, "The expected value should not be null.%n" + "If you were trying to filter on a null value, please use filteredOnNull(String propertyOrFieldName) instead"); }
/** * Check that the {@link LocalDate} to compare actual {@link LocalDate} to is not null, in that case throws a * {@link IllegalArgumentException} with an explicit message * * @param other the {@link LocalDate} to check * @throws IllegalArgumentException with an explicit message if the given {@link LocalDate} is null */ private static void assertLocalDateParameterIsNotNull(LocalDate other) { checkArgument(other != null, NULL_LOCAL_DATE_TIME_PARAMETER_MESSAGE); }
/** * Check that the {@link LocalTime} string representation to compare actual {@link LocalTime} to is not null, * otherwise throws a {@link IllegalArgumentException} with an explicit message * * @param localTimeAsString String representing the {@link LocalTime} to compare actual with * @throws IllegalArgumentException with an explicit message if the given {@link String} is null */ private static void assertLocalTimeAsStringParameterIsNotNull(String localTimeAsString) { checkArgument(localTimeAsString != null, "The String representing the LocalTime to compare actual with should not be null"); }
/** * Construct the delta for original and revised chunks * * @param original Chunk describing the original text. Must not be {@code null}. * @param revised Chunk describing the revised text. Must not be {@code null}. */ public Delta(Chunk<T> original, Chunk<T> revised) { checkArgument(original != null, "original must not be null"); checkArgument(revised != null, "revised must not be null"); this.original = original; this.revised = revised; }
/** * Check that the {@link ZonedDateTime} to compare actual {@link ZonedDateTime} to is not null, otherwise throws a * {@link IllegalArgumentException} with an explicit message * * @param dateTime the {@link ZonedDateTime} to check * @throws IllegalArgumentException with an explicit message if the given {@link ZonedDateTime} is null */ private static void assertDateTimeParameterIsNotNull(ZonedDateTime dateTime) { checkArgument(dateTime != null, NULL_DATE_TIME_PARAMETER_MESSAGE); }
/** * Check that the {@link ZonedDateTime} string representation to compare actual {@link ZonedDateTime} to is not null, * otherwise throws a {@link IllegalArgumentException} with an explicit message * * @param dateTimeAsString String representing the ZonedDateTime to compare actual with * @throws IllegalArgumentException with an explicit message if the given {@link String} is null */ private static void assertDateTimeAsStringParameterIsNotNull(String dateTimeAsString) { checkArgument(dateTimeAsString != null, "The String representing the ZonedDateTime to compare actual with should not be null"); }
/** * Check that the {@link java.time.OffsetDateTime} string representation to compare actual * {@link java.time.OffsetDateTime} to is not null, * otherwise throws a {@link IllegalArgumentException} with an explicit message * * @param offsetDateTimeAsString String representing the {@link java.time.OffsetDateTime} to compare actual with * @throws IllegalArgumentException with an explicit message if the given {@link String} is null */ private static void assertOffsetDateTimeAsStringParameterIsNotNull(String offsetDateTimeAsString) { checkArgument(offsetDateTimeAsString != null, "The String representing the OffsetDateTime to compare actual with should not be null"); }
@SuppressWarnings("unchecked") @Override protected SELF newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable) { checkArgument(iterable instanceof List, "Expecting %s to be a List", iterable); return (SELF) new FactoryBasedNavigableListAssert<>((List<? extends ELEMENT>) iterable, FactoryBasedNavigableListAssert.class, assertFactory); }
@SuppressWarnings("unchecked") private static <T> List<T> asList(Object array) { if (array == null) return null; checkArgument(isArray(array), "The object should be an array"); int length = getLength(array); List<T> list = new ArrayList<>(length); for (int i = 0; i < length; i++) { list.add((T) Array.get(array, i)); } return list; }
/** * Creates a new {@link Index}. * * @param value the value of the index. * @return the created {@code Index}. * @throws IllegalArgumentException if the given value is negative. */ public static Index atIndex(int value) { checkArgument(value >= 0, "The value of the index should not be negative"); return new Index(value); }
/** * Specifies the name of the charset to use for text-based assertions on the file's contents. * * @param charsetName the name of the charset to use. * @return {@code this} assertion object. * @throws IllegalArgumentException if the given encoding is not supported on this platform. */ @CheckReturnValue public SELF usingCharset(String charsetName) { checkArgument(Charset.isSupported(charsetName), "Charset:<'%s'> is not supported on this system", charsetName); return usingCharset(Charset.forName(charsetName)); }
public OnFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType, String... fields) { super(comparatorByPropertyOrField, comparatorByType); checkArgument(!isNullOrEmpty(fields), "No fields/properties specified"); for (String field : fields) { checkArgument(!isNullOrEmpty(field) && !isNullOrEmpty(field.trim()), "Null/blank fields/properties are invalid, fields/properties were %s", CONFIGURATION_PROVIDER.representation().toStringOf(fields)); } this.fields = fields; }
public static ErrorMessageFactory shouldHaveCause(Throwable actualCause, Throwable expectedCause) { checkArgument(expectedCause != null, "expected cause should not be null"); // actualCause has no cause if (actualCause == null) return new ShouldHaveCause(expectedCause); // same message => different type if (areEqual(actualCause.getMessage(), expectedCause.getMessage())) return new ShouldHaveCause(actualCause, expectedCause.getClass()); // same type => different message if (areEqual(actualCause.getClass(), expectedCause.getClass())) return new ShouldHaveCause(actualCause, expectedCause.getMessage()); return new ShouldHaveCause(actualCause, expectedCause); }
public void assertDecodedAs(String jsonValue, Type type, Slice expectedValue) { checkArgument(type.getJavaType() == Slice.class, "Wrong (not Slice based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getSlice(), expectedValue); }
public void assertDecodedAs(String jsonValue, Type type, boolean expectedValue) { checkArgument(type.getJavaType() == boolean.class, "Wrong (not boolean based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getBoolean(), expectedValue); }
public void assertDecodedAs(String jsonValue, Type type, double expectedValue) { checkArgument(type.getJavaType() == double.class, "Wrong (not double based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getDouble(), expectedValue); }
public void assertDecodedAs(String jsonValue, Type type, long expectedValue) { checkArgument(type.getJavaType() == long.class, "Wrong (not long based) presto type '%s'", type); FieldValueProvider decodedValue = decode(Optional.of(jsonValue), type); assertFalse(decodedValue.isNull(), format("expected non null when decoding %s as %s", jsonValue, type)); assertEquals(decodedValue.getLong(), expectedValue); }