From 27019b23c195c546cda1e93391b5660e4e88c33d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 9 Dec 2017 17:35:18 +0000 Subject: [PATCH] Update and clarify TypeAlias tests --- .../java/net/kemitix/mon/TypeAliasTest.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/test/java/net/kemitix/mon/TypeAliasTest.java b/src/test/java/net/kemitix/mon/TypeAliasTest.java index c462d8b..a077205 100644 --- a/src/test/java/net/kemitix/mon/TypeAliasTest.java +++ b/src/test/java/net/kemitix/mon/TypeAliasTest.java @@ -1,9 +1,11 @@ package net.kemitix.mon; +import org.assertj.core.util.Strings; import org.junit.Test; +import java.util.Arrays; import java.util.Collections; -import java.util.function.Function; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -16,7 +18,7 @@ public class TypeAliasTest { //when final TypeAlias typeAlias = givenTypeAlias(value); //then - assertThat(typeAlias.map(value::equals)).isTrue(); + assertThat(typeAlias.getValue()).isSameAs(value); } private TypeAlias givenTypeAlias(final String value) { @@ -33,17 +35,17 @@ public class TypeAliasTest { new TypeAlias>(iterable) { }; //then - assertThat(typeAlias.map(iterable::equals)).isTrue(); + assertThat(typeAlias.getValue()).isSameAs(iterable); } @Test - public void shouldCreateAnAliasedTypeAndGetTheValue() { + public void shouldCreateATypeAliasSubclassAndGetTheValue() { //given final String value = "value"; //when final AnAlias anAlias = AnAlias.of(value); //then - assertThat(anAlias.map(value::equals)).isTrue(); + assertThat(anAlias.getValue()).isSameAs(value); } @Test @@ -67,7 +69,7 @@ public class TypeAliasTest { } @Test - public void shouldBeEqualToUnAliasedValue() { + public void shouldBeEqualToRawValue() { //given final String value = "value"; final AnAlias anAlias = AnAlias.of(value); @@ -87,22 +89,22 @@ public class TypeAliasTest { @Test public void shouldHaveSameToStringAsAliasedType() { //given - final String value = "value"; + final List value = Arrays.asList(1, 2, 3); //when - final AnAlias anAlias = AnAlias.of(value); + final TypeAlias> anAlias = new TypeAlias>(value) { + }; //then - assertThat(anAlias.toString()).isEqualTo(value); + assertThat(anAlias.toString()).isEqualTo(value.toString()); } @Test public void shouldMapTypeAlias() { //given final AnAlias anAlias = AnAlias.of("text"); - final Function function = v -> v; //when - final String value = anAlias.map(function); + final String value = anAlias.map(Strings::quote); //then - assertThat(value).isEqualTo("text"); + assertThat(value).isEqualTo("'text'"); } private static class AnAlias extends TypeAlias {