Skip to content

Commit

Permalink
fixed line trimming bug
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Mar 30, 2017
1 parent 57d0d24 commit c6b1c42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/amihaiemil/camel/NoCommentsYamlLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public int compareTo(final YamlLine other) {
*/
@Override
public String trimmed() {
String trimmed = this.line.toString();
String trimmed = this.line.trimmed();
int i = 0;
while(i < trimmed.length()) {
if(trimmed.charAt(i) == '#') {
Expand All @@ -74,7 +74,7 @@ public String trimmed() {
}
i++;
}
return trimmed;
return trimmed.trim();
}

@Override
Expand All @@ -94,6 +94,6 @@ public boolean hasNestedNode() {

@Override
public String toString() {
return this.trimmed().toString();
return this.line.toString();
}
}
7 changes: 1 addition & 6 deletions src/test/java/com/amihaiemil/camel/RtYamlInputTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;

/**
Expand All @@ -20,13 +19,8 @@ public final class RtYamlInputTest {
/**
* YamlMapping can be read without its comments.
* @throws Exception If something goes wrong
* @todo #98:30m/DEV There is a bug in ReadYamlMapping.children(), the
* maps' values are not returned properly. Because of that,
* YamlMapping.equals does not work fine. Fix the bug and activate this
* unit test.
*/
@Test
@Ignore
public void readsMappingWithoutComments() throws Exception {
YamlMapping expected = Yaml.createYamlMappingBuilder()
.add("name", "camel")
Expand Down Expand Up @@ -67,6 +61,7 @@ public void readsMappingWithoutComments() throws Exception {
read.yamlSequence("developers").string(2),
Matchers.equalTo(expected.yamlSequence("developers").string(2))
);
System.out.println(read);
MatcherAssert.assertThat(
read, Matchers.equalTo(expected)
);
Expand Down

0 comments on commit c6b1c42

Please sign in to comment.