com.insightfullogic.lambdabehave.expectations.ArrayExpectation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lambda-behave Show documentation
Show all versions of lambda-behave Show documentation
A modern testing and behavioural specification framework for Java 8
package com.insightfullogic.lambdabehave.expectations;
import org.hamcrest.Matcher;
import java.util.Collection;
import java.util.List;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
public final class ArrayExpectation extends BoundExpectation {
ArrayExpectation(final T[] array, final boolean positive) {
super(array, positive);
}
public ArrayExpectation isArrayWithSize(final int size) {
return matches(arrayWithSize(size));
}
public ArrayExpectation isArrayWithSize(final Matcher super Integer> matcher) {
return matches(arrayWithSize(matcher));
}
public ArrayExpectation isArray(final Matcher super T> ... elementMatchers) {
return matches(array(elementMatchers));
}
public ArrayExpectation isArrayContaining(final T ... items) {
return matches(arrayContaining(items));
}
public ArrayExpectation isArrayContaining(final Matcher super T> ... elements) {
return matches(arrayContaining(elements));
}
public ArrayExpectation isArrayContaining(final List> elements) {
return matches(arrayContaining(elements));
}
public ArrayExpectation isArrayContainingInAnyOrder(final T ... items) {
return matches(arrayContainingInAnyOrder(items));
}
public ArrayExpectation isArrayContainingInAnyOrder(final Matcher super T> ... elements) {
return matches(arrayContainingInAnyOrder(elements));
}
public ArrayExpectation isArrayContainingInAnyOrder(final Collection> elements) {
return matches(arrayContainingInAnyOrder(elements));
}
public ArrayExpectation isEmptyArray() {
return matches(emptyArray());
}
public ArrayExpectation isArrayWithItem(final T item) {
return matches(hasItemInArray(item));
}
public ArrayExpectation isArrayWithItem(final Matcher super T> itemMatcher) {
return matches(hasItemInArray(itemMatcher));
}
@Override
public ArrayExpectation isEqualTo(final T[] expected) {
super.isEqualTo(expected);
return this;
}
@Override
public ArrayExpectation hasToString(final Matcher super String> str) {
super.hasToString(str);
return this;
}
@Override
public ArrayExpectation hasToString(final String arg) {
super.hasToString(arg);
return this;
}
@Override
public ArrayExpectation instanceOf(final Class> arg) {
super.instanceOf(arg);
return this;
}
@Override
public ArrayExpectation isNotNull() {
super.isNotNull();
return this;
}
@Override
public ArrayExpectation toBeNull() {
super.toBeNull();
return this;
}
@Override
public ArrayExpectation sameInstance(final T[] target) {
super.sameInstance(target);
return this;
}
@Override
public ArrayExpectation any() {
super.any();
return this;
}
@Override
public ArrayExpectation hasProperty(final String propertyName, final Matcher> propertyValue) {
super.hasProperty(propertyName, propertyValue);
return this;
}
@Override
public ArrayExpectation is(final T[] value) {
super.is(value);
return this;
}
@Override
public ArrayExpectation is(final Matcher super T[]> matcher) {
super.is(matcher);
return this;
}
@Override
public ArrayExpectation isIn(final Collection values) {
super.isIn(values);
return this;
}
@Override
public ArrayExpectation isIn(final T[] ... values) {
super.isIn(values);
return this;
}
@Override
public ArrayExpectation never() {
super.never();
return this;
}
private ArrayExpectation matches(final Matcher super T[]> matcher) {
assertThat(objectUnderTest, matcher);
return this;
}
}