diff options
Diffstat (limited to 'yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java')
-rw-r--r-- | yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java b/yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java new file mode 100644 index 00000000000..e8a8f9309b0 --- /dev/null +++ b/yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java @@ -0,0 +1,55 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.yolean.chain; + +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +/** + * @author tonytv + */ +public class ChainTest { + + public static class Filter { + + } + + public static class OtherFilter extends Filter { + + } + + @Test + public void empty_chain_toString() { + Chain<Filter> c = new Chain<>("myChain"); + assertThat(c.toString(), is("chain 'myChain'{}")); + } + + @Test + public void singleton_chain_toString() { + Chain<Filter> c = new Chain<>("myChain", new Filter()); + assertThat(c.toString(), is("chain 'myChain'{ Filter }")); + } + + @Test + public void chain_toString() { + Chain<Filter> c = new Chain<>("myChain", new Filter(), new Filter(), new OtherFilter()); + assertThat(c.toString(), is("chain 'myChain'{ Filter -> Filter -> OtherFilter }")); + } + + @Test + public void non_equal_due_to_different_components() { + assertThat(new Chain<>("a", new Filter()), is(not(new Chain<>("a", new Filter())))); + } + + @Test + public void non_equal_due_to_different_size_comopnents() { + assertThat(new Chain<>("a", new Filter()), is(not(new Chain<Filter>("a")))); + } + + @Test + public void hashCode_equals() { + assertThat(new Chain<>("a").hashCode(), is(new Chain<Filter>("a").hashCode())); + } +} |