Package net.emaze.dysfunctional.collections

Source Code of net.emaze.dysfunctional.collections.CollectionAllAdderTest

package net.emaze.dysfunctional.collections;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.emaze.dysfunctional.dispatching.delegates.Delegate;
import net.emaze.dysfunctional.testing.O;
import org.junit.Assert;
import org.junit.Test;

/**
*
* @author rferranti
*/
public class CollectionAllAdderTest {

    @Test(expected = IllegalArgumentException.class)
    public void creatingCollecitonAdderWithNullCollectionYieldsException() {
        new CollectionAllAdder<Collection<O>, O>(null);
    }

    @Test
    public void canAddToCollection() {
        final List<O> bucket = new ArrayList<O>();
        new CollectionAllAdder<List<O>, O>(bucket).perform(Arrays.asList(O.ONE));
        Assert.assertEquals(1, bucket.size());
    }

    @Test(expected = ClassCastException.class)
    public void passingWrongTypeToErasureYieldsException() {
        final List<O> bucket = new ArrayList<O>();
        Delegate d = new CollectionAllAdder<List<O>, O>(bucket);
        d.perform(new Object());
    }
}
TOP

Related Classes of net.emaze.dysfunctional.collections.CollectionAllAdderTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.