All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.insightfullogic.lambdabehave.expectations.ArrayExpectation Maven / Gradle / Ivy

There is a newer version: 0.4
Show newest version
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 matcher) {
        return matches(arrayWithSize(matcher));
    }

    public ArrayExpectation isArray(final Matcher ... elementMatchers) {
        return matches(array(elementMatchers));
    }

    public ArrayExpectation isArrayContaining(final T ... items) {
        return matches(arrayContaining(items));
    }

    public ArrayExpectation isArrayContaining(final Matcher ... 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 ... 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 itemMatcher) {
        return matches(hasItemInArray(itemMatcher));
    }

    @Override
    public ArrayExpectation isEqualTo(final T[] expected) {
        super.isEqualTo(expected);
        return this;
    }

    @Override
    public ArrayExpectation hasToString(final Matcher 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 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 matcher) {
        assertThat(objectUnderTest, matcher);
        return this;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy