Repository: decorators-squad/eo-yaml
Pull request #535 (2022-11-26 14:25:14)

#531 implemented, tested and used the Edited YamlLine
PR for #531 

Implemented, tested and used the Edited YamlLine.
Refactored to have the proper default methods on YamlLine interface (added the value() method); 


Patch:
diff --git a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
index 37b83c2..938ea66 100644
--- a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
+++ b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
@@ -134,9 +134,6 @@ final class AllYamlLines implements YamlLines {
      * after the given line.
      * @param prev YamlLine just previous to the node we're trying to find.
      * @return Found YamlNode.
-     * @todo #529:60min Implement, test and use Edited YamlLine here.
-     *  A YamlLine to which we append some text and it keeps the indentation,
-     *  number etc of the original line.
      */
     private YamlNode mappingSequenceOrPlainScalar(final YamlLine prev) {
         YamlNode node = null;
@@ -161,8 +158,8 @@ final class AllYamlLines implements YamlLines {
         ) {
             node = new ReadPlainScalar(
                 this,
-                new RtYamlLine(prev.trimmed()
-                    + " null #" + prev.comment(), prev.number())
+                new Edited(prev.trimmed()
+                    + " null #" + prev.comment(), prev)
             );
         } else {
             Matcher matcher = SEQUENCE_OR_MAP.matcher(first.trimmed());
diff --git a/src/main/java/com/amihaiemil/eoyaml/CachedYamlLine.java b/src/main/java/com/amihaiemil/eoyaml/Edited.java
similarity index 50%
rename from src/main/java/com/amihaiemil/eoyaml/CachedYamlLine.java
rename to src/main/java/com/amihaiemil/eoyaml/Edited.java
index 9579aaa..1b93c3f 100644
--- a/src/main/java/com/amihaiemil/eoyaml/CachedYamlLine.java
+++ b/src/main/java/com/amihaiemil/eoyaml/Edited.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2016-2020, Mihai Emil Andronache
+ * Copyright (c) 2016-2023, Mihai Emil Andronache
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,98 +28,45 @@
 package com.amihaiemil.eoyaml;
 
 /**
- * Decorator class to cache values of trimmed() and indentation() method for
- * a YamlLine.
- * @author Sherif Waly (sherifwaly95@gmail.com)
+ * A YamlLine with contents edited by us.
+ * @author Mihai Andronache (amihaiemil@gmail.com)
  * @version $Id$
- * @since 1.0.0
- *
+ * @since 7.0.0
  */
-final class CachedYamlLine implements YamlLine {
-
-    /**
-     * Content line.
-     */
-    private YamlLine line;
-
-    /**
-     * Cached trimmed line.
-     */
-    private String trimmed;
-
-    /**
-     * Cached contents line.
-     */
-    private String contents;
-
+final class Edited implements YamlLine {
     /**
-     * Cached indentation.
+     * New content of the YamlLine.
      */
-    private int indentation = -1;
+    private final String newContent;
 
     /**
-     * Cached value.
+     * Original YamlLine to preserve other suff besides the new content.
      */
-    private Boolean hasNestedNode;
+    private final YamlLine original;
 
     /**
      * Ctor.
-     * @param line YamlLine
+     * @param newContent New content of the line.
+     * @param original Original line to preserveother stuff such as indentation
+     *  and line number.
      */
-    CachedYamlLine(final YamlLine line) {
-        this.line = line;
-    }
-
-    @Override
-    public int compareTo(final YamlLine other) {
-        return this.line.compareTo(other);
+    Edited(final String newContent, final YamlLine original) {
+        this.newContent = newContent;
+        this.original = original;
     }
 
     @Override
-    public String trimmed() {
-        if(this.trimmed == null) {
-            this.trimmed = this.line.trimmed();
-        }
-        return this.trimmed;
-    }
-
-    @Override
-    public String contents(final int previousIndent) {
-        if(this.contents == null) {
-            this.contents = this.line.contents(previousIndent);
-        }
-        return this.contents;
-    }
-
-    @Override
-    public String comment() {
-        return this.line.comment();
+    public String value() {
+        return this.newContent;
     }
 
     @Override
     public int number() {
-        return this.line.number();
+        return this.original.number();
     }
 
     @Override
     public int indentation() {
-        if(this.indentation == -1) {
-            this.indentation = this.line.indentation();
-        }
-        return this.indentation;
+        return this.original.indentation();
     }
-
-    @Override
-    public boolean requireNestedIndentation() {
-        if (this.hasNestedNode == null) {
-            this.hasNestedNode = this.line.requireNestedIndentation();
-        }
-        return this.hasNestedNode;
-    }
-
-    @Override
-    public String toString() {
-        return this.line.toString();
-    }
-
 }
diff --git a/src/main/java/com/amihaiemil/eoyaml/Indented.java b/src/main/java/com/amihaiemil/eoyaml/Indented.java
index 1006c4b..b662b81 100644
--- a/src/main/java/com/amihaiemil/eoyaml/Indented.java
+++ b/src/main/java/com/amihaiemil/eoyaml/Indented.java
@@ -57,18 +57,8 @@ final class Indented implements YamlLine {
     }
 
     @Override
-    public String trimmed() {
-        return this.original.trimmed();
-    }
-
-    @Override
-    public String contents(final int previousIndent) {
-        return this.original.contents(previousIndent);
-    }
-
-    @Override
-    public String comment() {
-        return this.original.comment();
+    public String value() {
+        return this.original.value();
     }
 
     @Override
@@ -80,14 +70,4 @@ final class Indented implements YamlLine {
     public int indentation() {
         return this.indentation;
     }
-
-    @Override
-    public boolean requireNestedIndentation() {
-        return this.original.requireNestedIndentation();
-    }
-
-    @Override
-    public int compareTo(final YamlLine other) {
-        return this.original.compareTo(other);
-    }
 }
diff --git a/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java b/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java
index 1ff0717..d2e1190 100644
--- a/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java
+++ b/src/main/java/com/amihaiemil/eoyaml/RtYamlLine.java
@@ -27,8 +27,6 @@
  */
 package com.amihaiemil.eoyaml;
 
-import com.amihaiemil.eoyaml.exceptions.YamlReadingException;
-
 /**
  * Default implementation of {@link YamlLine}.
  * "Rt" stands for "Runtime".
@@ -60,67 +58,8 @@ final class RtYamlLine implements YamlLine {
     }
 
     @Override
-    public String trimmed() {
-        String trimmed = this.value.trim();
-        int i = 0;
-        while(i < trimmed.length()) {
-            if(i > 0 && trimmed.charAt(i) == '#') {
-                trimmed = trimmed.substring(0, i);
-                break;
-            } else if(trimmed.charAt(i) == '"') {
-                i++;
-                while(i < trimmed.length() && trimmed.charAt(i) != '"') {
-                    i++;
-                }
-            } else if(trimmed.charAt(i) == '\'') {
-                i++;
-                while(i < trimmed.length() && trimmed.charAt(i) != '\'') {
-                    i++;
-                }
-            }
-            i++;
-        }
-        return trimmed.trim();
-    }
-
-    @Override
-    public String contents(final int previousIndent) {
-        String contents;
-        int indentation = indentation();
-        if (indentation == 0 && previousIndent <= 0) {
-            contents = this.value;
-        } else if (indentation > previousIndent) {
-            contents = this.value.substring(previousIndent + 2);
-        } else {
-            throw new YamlReadingException("Literal must be indented "
-                    + "at least 2 spaces from previous element.");
-        }
-        return contents;
-    }
-
-    @Override
-    public String comment() {
-        String comment = "";
-        String trimmed = this.value.trim();
-        int i = 0;
-        while(i < trimmed.length()) {
-            if(trimmed.charAt(i) == '#') {
-                comment = trimmed.substring(i + 1);
-                break;
-            } else if(trimmed.charAt(i) == '"') {
-                i++;
-                while(i < trimmed.length() && trimmed.charAt(i) != '"') {
-                    i++;
-                }
-            } else if(trimmed.charAt(i) == '\'') {
-                i++;
-                while(i < trimmed.length() && trimmed.charAt(i) != '\'') {
-                    i++;
-                }
-            }
-            i++;
-        }
-        return comment.trim();
+    public String value() {
+        return this.value;
     }
 
     @Override
@@ -141,32 +80,4 @@ final class RtYamlLine implements YamlLine {
     public String toString() {
         return this.value;
     }
-
-    @Override
-    public int compareTo(final YamlLine other) {
-        int result = -1;
-        if (this == other) {
-            result = 0;
-        } else if (other == null) {
-            result = 1;
-        } else {
-            result = this.trimmed().compareTo(other.trimmed());
-        }
-        return result;
-    }
-
-    @Override
-    public boolean requireNestedIndentation() {
-        final boolean result;
-
-        if("---".equals(this.trimmed())) {
-            result = false;
-        } else {
-            final String specialCharacters = "-?";
-            final CharSequence prevLineLastChar =
-                this.trimmed().substring(this.trimmed().length() - 1);
-            result = specialCharacters.contains(prevLineLastChar);
-        }
-        return result;
-    }
 }
diff --git a/src/main/java/com/amihaiemil/eoyaml/Skip.java b/src/main/java/com/amihaiemil/eoyaml/Skip.java
index f5d243e..2901657 100644
--- a/src/main/java/com/amihaiemil/eoyaml/Skip.java
+++ b/src/main/java/com/amihaiemil/eoyaml/Skip.java
@@ -166,18 +166,8 @@ final class Skip implements YamlLines {
         }
 
         @Override
-        public String trimmed() {
-            return this.current.trimmed();
-        }
-
-        @Override
-        public String contents(final int previousIndent) {
-            return this.current.contents(previousIndent);
-        }
-
-        @Override
-        public String comment() {
-            return this.current.comment();
+        public String value() {
+            return this.current.value();
         }
 
         @Override
@@ -190,16 +180,6 @@ final class Skip implements YamlLines {
             return this.current.indentation();
         }
 
-        @Override
-        public boolean requireNestedIndentation() {
-            return this.current.requireNestedIndentation();
-        }
-
-        @Override
-        public int compareTo(final YamlLine other) {
-            return this.current.compareTo(other);
-        }
-
         /**
          * Previous line. Usually a skip {@link Line}
          * @return YamlLine.
diff --git a/src/main/java/com/amihaiemil/eoyaml/YamlLine.java b/src/main/java/com/amihaiemil/eoyaml/YamlLine.java
index a528b60..f023366 100644
--- a/src/main/java/com/amihaiemil/eoyaml/YamlLine.java
+++ b/src/main/java/com/amihaiemil/eoyaml/YamlLine.java
@@ -27,6 +27,8 @@
  */
 package com.amihaiemil.eoyaml;
 
+import com.amihaiemil.eoyaml.exceptions.YamlReadingException;
+
 /**
  * A line of yaml.
  * @author Mihai Andronache (amihaiemil@gmail.com)
@@ -40,11 +42,38 @@ interface YamlLine extends Comparable<YamlLine> {
      */
     int UNKNOWN_LINE_NUMBER = -1;
 
+    /**
+     * The line's value, untrimmed, containing comments etc.
+     * @return String.
+     */
+    String value();
+
     /**
      * The line's trimmed contents with comments, aliases etc removed.
      * @return Trimmed string (leading and trailing spaces) contents.
      */
-    String trimmed();
+    default String trimmed() {
+        String trimmed = this.value().trim();
+        int i = 0;
+        while(i < trimmed.length()) {
+            if(i > 0 && trimmed.charAt(i) == '#') {
+                trimmed = trimmed.substring(0, i);
+                break;
+            } else if(trimmed.charAt(i) == '"') {
+                i++;
+                while(i < trimmed.length() && trimmed.charAt(i) != '"') {
+                    i++;
+                }
+            } else if(trimmed.charAt(i) == '\'') {
+                i++;
+                while(i < trimmed.length() && trimmed.charAt(i) != '\'') {
+                    i++;
+                }
+            }
+            i++;
+        }
+        return trimmed.trim();
+    }
 
     /**
      * The line's contents with spaces, tabs, etc maintained.
@@ -52,13 +81,47 @@ interface YamlLine extends Comparable<YamlLine> {
      *                       to remove leading spaces.
      * @return String line contents.
      */
-    String contents(int previousIndent);
+    default String contents(final int previousIndent) {
+        String contents;
+        int indentation = indentation();
+        if (indentation == 0 && previousIndent <= 0) {
+            contents = this.value();
+        } else if (indentation > previousIndent) {
+            contents = this.value().substring(previousIndent + 2);
+        } else {
+            throw new YamlReadingException("Literal must be indented "
+                + "at least 2 spaces from previous element.");
+        }
+        return contents;
+    }
 
     /**
      * Return the comment, if any, from this line.
      * @return Comment of empty string.
      */
-    String comment();
+    default String comment() {
+        String comment = "";
+        String trimmed = this.value().trim();
+        int i = 0;
+        while(i < trimmed.length()) {
+            if(trimmed.charAt(i) == '#') {
+                comment = trimmed.substring(i + 1);
+                break;
+            } else if(trimmed.charAt(i) == '"') {
+                i++;
+                while(i < trimmed.length() && trimmed.charAt(i) != '"') {
+                    i++;
+                }
+            } else if(trimmed.charAt(i) == '\'') {
+                i++;
+                while(i < trimmed.length() && trimmed.charAt(i) != '\'') {
+                    i++;
+                }
+            }
+            i++;
+        }
+        return comment.trim();
+    }
 
     /**
      * Number of the line (count start from 0).
@@ -78,7 +141,37 @@ interface YamlLine extends Comparable<YamlLine> {
      * Do the following line(s) require a deeper indentation than this line's?
      * @return True or false
      */
-    boolean requireNestedIndentation();
+    default boolean requireNestedIndentation() {
+        final boolean result;
+
+        if("---".equals(this.trimmed())) {
+            result = false;
+        } else {
+            final String specialCharacters = "-?";
+            final CharSequence prevLineLastChar =
+                this.trimmed().substring(this.trimmed().length() - 1);
+            result = specialCharacters.contains(prevLineLastChar);
+        }
+        return result;
+    }
+
+    /**
+     * Compare this line to another.
+     * @param other Other line to compare.
+     * @return Zero if same line object, 1 if other is null, or string
+     *  comparison of the trimmed (no spaces or comments) values.
+     */
+    default int compareTo(final YamlLine other) {
+        int result = -1;
+        if (this == other) {
+            result = 0;
+        } else if (other == null) {
+            result = 1;
+        } else {
+            result = this.trimmed().compareTo(other.trimmed());
+        }
+        return result;
+    }
 
     /**
      * YamlLine null object.
@@ -86,17 +179,17 @@ interface YamlLine extends Comparable<YamlLine> {
     class NullYamlLine implements YamlLine {
 
         @Override
-        public String trimmed() {
+        public String value() {
             return "";
         }
 
         @Override
-        public String contents(final int previousIndent) {
+        public String trimmed() {
             return "";
         }
 
         @Override
-        public String comment() {
+        public String contents(final int previousIndent) {
             return "";
         }
 
@@ -110,15 +203,5 @@ interface YamlLine extends Comparable<YamlLine> {
             return -1;
         }
 
-        @Override
-        public int compareTo(final YamlLine other) {
-            return -1;
-        }
-
-        @Override
-        public boolean requireNestedIndentation() {
-            return false;
-        }
-
     }
 }


Test patch:
diff --git a/src/test/java/com/amihaiemil/eoyaml/CachedYamlLineTest.java b/src/test/java/com/amihaiemil/eoyaml/CachedYamlLineTest.java
deleted file mode 100644
index 389e45a..0000000
--- a/src/test/java/com/amihaiemil/eoyaml/CachedYamlLineTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Copyright (c) 2016-2020, Mihai Emil Andronache
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- *  list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright notice,
- *  this list of conditions and the following disclaimer in the documentation
- *  and/or other materials provided with the distribution.
- * Neither the name of the copyright holder nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-package com.amihaiemil.eoyaml;
-
-import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-/**
- * Unit Tests for {@link CachedYamlLine}.
- * @author Sherif Waly (sherifwaly95@gmail.com)
- * @version $Id$
- * @since 1.0.0
- *
- */
-public final class CachedYamlLineTest {
-
-    /**
-     * CachedIndentedLine knows its number.
-     */
-    @Test
-    public void knowsNumber() {
-        YamlLine line = new CachedYamlLine(
-            new RtYamlLine("this line", 12)
-        );
-        MatcherAssert.assertThat(line.number(), Matchers.is(12));
-    }
-
-    /**
-     * CachedIndentedLine caches trimmed String and returns same object.
-     */
-    @Test
-    public void cachesTrimmedValue() {
-        YamlLine mock = Mockito.mock(YamlLine.class);
-        Mockito.when(mock.trimmed())
-            .thenReturn("this line")
-            .thenThrow(new RuntimeException());
-        YamlLine line = new CachedYamlLine(mock);
-        MatcherAssert.assertThat(line.trimmed(), Matchers.is("this line"));
-        MatcherAssert.assertThat(line.trimmed(), Matchers.is("this line"));
-    }
-
-    /**
-     * CachedIndentedLine caches indentation value and doesn't recalculate it.
-     */
-    @Test
-    public void cachesIndentationValue() {
-        YamlLine mock = Mockito.mock(YamlLine.class);
-        Mockito.when(mock.indentation())
-            .thenReturn(12)
-            .thenThrow(new RuntimeException());
-        YamlLine cachedLine = new CachedYamlLine(mock);
-        MatcherAssert.assertThat(cachedLine.indentation(), Matchers.is(12));
-        MatcherAssert.assertThat(cachedLine.indentation(), Matchers.is(12));
-    }
-
-    /**
-     * CachedIndentedLine caches contents value and doesn't recalculate it.
-     */
-    @Test
-    public void cachesContentValue() {
-        YamlLine mock = Mockito.mock(YamlLine.class);
-        Mockito.when(mock.contents(12))
-                .thenReturn("this line")
-                .thenThrow(new RuntimeException());
-        YamlLine line = new CachedYamlLine(mock);
-        MatcherAssert.assertThat(line.contents(12), Matchers.is("this line"));
-        MatcherAssert.assertThat(line.contents(12), Matchers.is("this line"));
-    }
-}
diff --git a/src/test/java/com/amihaiemil/eoyaml/EditedTestCase.java b/src/test/java/com/amihaiemil/eoyaml/EditedTestCase.java
new file mode 100644
index 0000000..a654c8b
--- /dev/null
+++ b/src/test/java/com/amihaiemil/eoyaml/EditedTestCase.java
@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) 2016-2023, Mihai Emil Andronache
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ *  list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright notice,
+ *  this list of conditions and the following disclaimer in the documentation
+ *  and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+package com.amihaiemil.eoyaml;
+
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+/**
+ * Unit tests for {@link Edited}.
+ * @author Mihai Andronache (amihaiemil@gmail.com)
+ * @version $Id$
+ * @since 7.0.0
+ */
+public final class EditedTestCase {
+
+    /**
+     * Edited returns the newContent as value().
+     */
+    @Test
+    public void returnsNewContentAsValue() {
+        final YamlLine original = Mockito.mock(YamlLine.class);
+        MatcherAssert.assertThat(
+            new Edited("my new content", original).value(),
+            Matchers.equalTo("my new content")
+        );
+        Mockito.verify(original, Mockito.times(0)).value();
+    }
+
+    /**
+     * Edited returns the comment from the newContent.
+     */
+    @Test
+    public void returnsNewContentAsComment() {
+        final YamlLine original = Mockito.mock(YamlLine.class);
+        MatcherAssert.assertThat(
+            new Edited("my new content # comment here", original)
+                .comment(),
+            Matchers.equalTo("comment here")
+        );
+        Mockito.verify(original, Mockito.times(0)).comment();
+    }
+
+    /**
+     * Edited returns the original YamlLine's number.
+     */
+    @Test
+    public void returnsOriginalLineNumber() {
+        final YamlLine original = Mockito.mock(YamlLine.class);
+        Mockito.when(original.number()).thenReturn(35);
+        MatcherAssert.assertThat(
+            new Edited("my new content", original).number(),
+            Matchers.equalTo(35)
+        );
+        Mockito.verify(original, Mockito.times(1)).number();
+    }
+
+    /**
+     * Edited returns the original YamlLine's indentation.
+     */
+    @Test
+    public void returnsOriginalIndentation() {
+        final YamlLine original = Mockito.mock(YamlLine.class);
+        Mockito.when(original.indentation()).thenReturn(16);
+        MatcherAssert.assertThat(
+            new Edited("my new content", original).indentation(),
+            Matchers.equalTo(16)
+        );
+        Mockito.verify(original, Mockito.times(1)).indentation();
+    }
+
+}
diff --git a/src/test/java/com/amihaiemil/eoyaml/RtYamlLineTest.java b/src/test/java/com/amihaiemil/eoyaml/RtYamlLineTest.java
index c5a89ba..692f348 100644
--- a/src/test/java/com/amihaiemil/eoyaml/RtYamlLineTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/RtYamlLineTest.java
@@ -73,6 +73,21 @@ public final class RtYamlLineTest {
         );
     }
 
+    /**
+     * RtYamlLine can its untrimmed, original value.
+     */
+    @Test
+    public void returnsValue() {
+        YamlLine line = new RtYamlLine(
+            "   this: line # with comment  ", 10
+        );
+        MatcherAssert.assertThat(
+            line.value(), Matchers.equalTo(
+                "   this: line # with comment  "
+            )
+        );
+    }
+
     /**
      * RtYamlLine can trim itself.
      */