Skip to content

Commit

Permalink
readsBlockSequence test
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed May 29, 2018
1 parent cf89666 commit 2f784ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/amihaiemil/camel/AbstractYamlSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public int compareTo(final YamlNode other) {
} else if (nodes.size() < others.size()) {
result = -1;
} else {
final Iterator<YamlNode> ietrator = others.iterator();
final Iterator<YamlNode> iterator = others.iterator();
final Iterator<YamlNode> here = nodes.iterator();
while(ietrator.hasNext()) {
result = here.next().compareTo(ietrator.next());
while(iterator.hasNext()) {
result = here.next().compareTo(iterator.next());
if(result != 0) {
break;
}
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/com/amihaiemil/camel/RtYamlInputTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amihaiemil.camel;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;

Expand Down Expand Up @@ -67,4 +68,25 @@ public void readsMappingWithoutComments() throws Exception {
);
}

/**
* A YamlSequence in block style can be read.
* @throws Exception If something goes wrong.
*/
@Test
public void readsBlockSequence() throws Exception {
YamlSequence expected = Yaml.createYamlSequenceBuilder()
.add("apples")
.add("pears")
.add("peaches")
.build();

YamlSequence read = new RtYamlInput(
new ByteArrayInputStream(
"- apples\n- pears\n- peaches".getBytes()
)
).readYamlSequence();

MatcherAssert.assertThat(read, Matchers.equalTo(expected));
}

}
6 changes: 4 additions & 2 deletions src/test/java/com/amihaiemil/camel/RtYamlSequenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -63,7 +62,10 @@ public void fetchesChildren() {
MatcherAssert.assertThat(
seq.children(), Matchers.not(Matchers.emptyIterable())
);
MatcherAssert.assertThat(seq.children().size(), Matchers.equalTo(3));
MatcherAssert.assertThat(
seq.children().size(),
Matchers.equalTo(3)
);
}

/**
Expand Down

0 comments on commit 2f784ac

Please sign in to comment.