Package com.humaorie.dollar

Source Code of com.humaorie.dollar.LazyMappedWrapperTest$IntegerToString

package com.humaorie.dollar;

import com.humaorie.dollar.ArrayWrapper.IntegerArrayWrapper;
import java.util.Iterator;
import org.junit.Assert;
import org.junit.Test;

public class LazyMappedWrapperTest {

    public static class IntegerToString implements Dollar.Function<String, Integer> {

        @Override
        public String call(Integer object) {
            return object.toString();
        }
    }

    @Test(expected = IllegalArgumentException.class)
    public void delegateMustBeNonNull() {
        new LazyMappedWrapper<String, Integer>(null, new IntegerToString());
    }

    @Test(expected = IllegalArgumentException.class)
    public void mapperMustBeNonNull() {
        new LazyMappedWrapper<String, Integer>(new RangeWrapper(1), null);
    }

    @Test
    public void appliesMapperToEveryElementProvidedByDelegate() {
        LazyMappedWrapper<String, Integer> wrapper = new LazyMappedWrapper<String, Integer>(new IntegerArrayWrapper(new int[]{1}), new IntegerToString());
        Iterator<String> iterator = wrapper.iterator();
        Assert.assertEquals("1", iterator.next());
    }
}
TOP

Related Classes of com.humaorie.dollar.LazyMappedWrapperTest$IntegerToString

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.