diff --git a/src/test/java/uk/co/caeldev/builder4test/DefaultLookUpTest.java b/src/test/java/uk/co/caeldev/builder4test/DefaultLookUpTest.java index e31721d..f6dfb82 100644 --- a/src/test/java/uk/co/caeldev/builder4test/DefaultLookUpTest.java +++ b/src/test/java/uk/co/caeldev/builder4test/DefaultLookUpTest.java @@ -1,6 +1,7 @@ package uk.co.caeldev.builder4test; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -15,6 +16,7 @@ public void setUp() { } @Test + @DisplayName("Should put and retrieve a value for a field") public void shouldPutAValue() { //Given Field field = new Field<>(); @@ -28,6 +30,7 @@ public void shouldPutAValue() { } @Test + @DisplayName("Should retrieve a value for a field") public void shouldGetAValueWhenExists() { //Given Field field = new Field<>(); @@ -43,6 +46,7 @@ public void shouldGetAValueWhenExists() { } @Test + @DisplayName("Should retrieve default values when there is no value for a field") public void shouldGetDefaultValueWhenItDoesExists() { //Given Field field = new Field<>(); @@ -55,6 +59,7 @@ public void shouldGetDefaultValueWhenItDoesExists() { } @Test + @DisplayName("Should retrieve null when there is null value for a field") public void shouldGetNullWhenItHasBeenOverrideWithNull() { //Given Field field = new Field<>(); @@ -70,6 +75,7 @@ public void shouldGetNullWhenItHasBeenOverrideWithNull() { } @Test + @DisplayName("Should retrieve null when there default is null") public void shouldGetNullWhenThereIsNoValueAndDefaultValueIsNull() { //Given Field field = new Field<>(); @@ -82,6 +88,7 @@ public void shouldGetNullWhenThereIsNoValueAndDefaultValueIsNull() { } @Test + @DisplayName("Should retrieve default value declared by using field constructor") public void shouldGetDefaultWhenItUseFieldDefaultValue() { //Given Field field = new Field<>("defaultValue"); @@ -94,6 +101,7 @@ public void shouldGetDefaultWhenItUseFieldDefaultValue() { } @Test + @DisplayName("Should retrieve null when there is no default value and no value for a field") public void shouldGetNullWhenThereIsNoDefaultValue() { //Given Field field = new Field<>(); @@ -106,6 +114,7 @@ public void shouldGetNullWhenThereIsNoDefaultValue() { } @Test + @DisplayName("Should override the default value set by field constructor by default value pass as argument ") public void shouldIgnoreDefaultValueBeenSetAtFieldInstantiation() { //Given Field field = new Field<>("defaultValue"); diff --git a/src/test/java/uk/co/caeldev/builder4test/ElementListBuilderTest.java b/src/test/java/uk/co/caeldev/builder4test/ElementListBuilderTest.java index 3fb6f36..a505837 100644 --- a/src/test/java/uk/co/caeldev/builder4test/ElementListBuilderTest.java +++ b/src/test/java/uk/co/caeldev/builder4test/ElementListBuilderTest.java @@ -1,5 +1,6 @@ package uk.co.caeldev.builder4test; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import uk.co.caeldev.builder4test.impl.Pojo; import uk.co.caeldev.builder4test.impl.PojoBuilder; @@ -11,6 +12,7 @@ class ElementListBuilderTest { @Test + @DisplayName("Should build different instances of ElementListBuilder") public void shouldBuilderDifferentBuilders() { //When ElementListBuilder pojoListBuilder = ElementListBuilder.elementListBuilder(PojoBuilder.creator); @@ -21,7 +23,8 @@ public void shouldBuilderDifferentBuilders() { } @Test - public void shouldBuildEmptyList() { + @DisplayName("Should build by default a list of one element where there is no size and elements definitions") + public void shouldBuildAListOfOneElement() { //When List pojos = ElementListBuilder.elementListBuilder(PojoBuilder.creator).get(); @@ -30,6 +33,7 @@ public void shouldBuildEmptyList() { } @Test + @DisplayName("Should build a list of one element when there is one element definition") public void shouldBuildListWithOneElement() { //When List pojos = ElementListBuilder.elementListBuilder(PojoBuilder.creator) @@ -48,6 +52,7 @@ public void shouldBuildListWithOneElement() { } @Test + @DisplayName("Should build a list of two elements when there is two element definitions") public void shouldBuildListWithTwoElements() { //When List pojos = ElementListBuilder.elementListBuilder(PojoBuilder.creator) diff --git a/src/test/java/uk/co/caeldev/builder4test/RandomLookUpTest.java b/src/test/java/uk/co/caeldev/builder4test/RandomLookUpTest.java index dec5135..ddd9e2a 100644 --- a/src/test/java/uk/co/caeldev/builder4test/RandomLookUpTest.java +++ b/src/test/java/uk/co/caeldev/builder4test/RandomLookUpTest.java @@ -2,6 +2,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Optional; @@ -13,6 +14,7 @@ class RandomLookUpTest { @Test + @DisplayName("Should get different random values for each field") public void shouldLookupARandomValue() { //Given Field field = new Field<>(); @@ -30,6 +32,7 @@ public void shouldLookupARandomValue() { } @Test + @DisplayName("Should get random and constant values") public void shouldLookupARandomValueAndConstantValue() { //Given Field field1 = new Field<>(); @@ -50,6 +53,7 @@ public void shouldLookupARandomValueAndConstantValue() { } @Test + @DisplayName("Should retrieve the constant value when there is a random value has well") public void shouldLookupConstantValueOverridesRandomValueForDoubleDefinition() { //Given Field field1 = new Field<>(); @@ -65,6 +69,7 @@ public void shouldLookupConstantValueOverridesRandomValueForDoubleDefinition() { } @Test + @DisplayName("Should retrieve the default value when there is no definition for that field") public void shouldLookupForDefaultValueWhenThereIsNoValue() { //Given Field field1 = new Field<>(); @@ -78,6 +83,7 @@ public void shouldLookupForDefaultValueWhenThereIsNoValue() { } @Test + @DisplayName("Should retrieve null when there is a null entry for a field") public void shouldLookupForNullWhenThereIsNullValueSet() { //Given Field field1 = new Field<>(); @@ -91,6 +97,7 @@ public void shouldLookupForNullWhenThereIsNullValueSet() { } @Test + @DisplayName("Should retrieve empty when the value is empty for a field") public void shouldLookupForEmptyWhenThereIsEmptyValueSet() { //Given Field field1 = new Field<>(); @@ -102,4 +109,21 @@ public void shouldLookupForEmptyWhenThereIsEmptyValueSet() { //Then assertThat(result1).isEmpty(); } + + @Test + @DisplayName("Should retrieve the value set by using put method for a field") + public void shouldLookupForValueInsertedByUsingPut() { + //Given + Field field1 = new Field<>(); + RandomLookUp lookUp = new RandomLookUp(Maps.newHashMap(), Maps.newHashMap()); + + //And + lookUp.put(field1, ""); + + //When + String result1 = lookUp.get(field1, "test"); + + //Then + assertThat(result1).isEmpty(); + } } \ No newline at end of file