diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-05-07 17:57:06 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-05-07 17:57:06 -0400 |
commit | df9dbddd378e6f5adadb3b62279fb80eb92b4a91 (patch) | |
tree | 611b28503262dd38e3432eb1e919d18df61d592f /sangria-core | |
parent | 39684339724ce966332deb846061d12701db99f2 (diff) | |
download | sangria-df9dbddd378e6f5adadb3b62279fb80eb92b4a91.tar.xz |
core: Change Priority.toString() to use more natural language.
Diffstat (limited to 'sangria-core')
-rw-r--r-- | sangria-core/src/main/java/com/tavianator/sangria/core/Priority.java | 13 | ||||
-rw-r--r-- | sangria-core/src/test/java/com/tavianator/sangria/core/PriorityTest.java | 18 |
2 files changed, 15 insertions, 16 deletions
diff --git a/sangria-core/src/main/java/com/tavianator/sangria/core/Priority.java b/sangria-core/src/main/java/com/tavianator/sangria/core/Priority.java index 6e6a2ea..a833883 100644 --- a/sangria-core/src/main/java/com/tavianator/sangria/core/Priority.java +++ b/sangria-core/src/main/java/com/tavianator/sangria/core/Priority.java @@ -126,23 +126,22 @@ public class Priority implements Comparable<Priority> { @Override public String toString() { - StringBuilder builder = new StringBuilder("Priority."); + StringBuilder builder = new StringBuilder(); if (weights.length == 0) { - builder.append("getDefault()"); + builder.append("default priority"); } else { - builder.append("create("); + builder.append("priority ["); for (int i = 0; i < weights.length; ++i) { if (i != 0) { builder.append(", "); } builder.append(weights[i]); } - builder.append(")"); + builder.append("]"); } if (seq != 0) { - builder.append(".next(") - .append(seq) - .append(")"); + builder.append(" + ") + .append(seq); } return builder.toString(); } diff --git a/sangria-core/src/test/java/com/tavianator/sangria/core/PriorityTest.java b/sangria-core/src/test/java/com/tavianator/sangria/core/PriorityTest.java index 7d90f57..0869565 100644 --- a/sangria-core/src/test/java/com/tavianator/sangria/core/PriorityTest.java +++ b/sangria-core/src/test/java/com/tavianator/sangria/core/PriorityTest.java @@ -85,16 +85,16 @@ public class PriorityTest { @Test public void testToString() { - assertThat(Priority.getDefault().toString(), equalTo("Priority.getDefault()")); - assertThat(Priority.getDefault().next().toString(), equalTo("Priority.getDefault().next(1)")); - assertThat(Priority.getDefault().next().next().toString(), equalTo("Priority.getDefault().next(2)")); + assertThat(Priority.getDefault().toString(), equalTo("default priority")); + assertThat(Priority.getDefault().next().toString(), equalTo("default priority + 1")); + assertThat(Priority.getDefault().next().next().toString(), equalTo("default priority + 2")); - assertThat(Priority.create(1).toString(), equalTo("Priority.create(1)")); - assertThat(Priority.create(1).next().toString(), equalTo("Priority.create(1).next(1)")); - assertThat(Priority.create(1).next().next().toString(), equalTo("Priority.create(1).next(2)")); + assertThat(Priority.create(1).toString(), equalTo("priority [1]")); + assertThat(Priority.create(1).next().toString(), equalTo("priority [1] + 1")); + assertThat(Priority.create(1).next().next().toString(), equalTo("priority [1] + 2")); - assertThat(Priority.create(1, 2).toString(), equalTo("Priority.create(1, 2)")); - assertThat(Priority.create(1, 2).next().toString(), equalTo("Priority.create(1, 2).next(1)")); - assertThat(Priority.create(1, 2).next().next().toString(), equalTo("Priority.create(1, 2).next(2)")); + assertThat(Priority.create(1, 2).toString(), equalTo("priority [1, 2]")); + assertThat(Priority.create(1, 2).next().toString(), equalTo("priority [1, 2] + 1")); + assertThat(Priority.create(1, 2).next().next().toString(), equalTo("priority [1, 2] + 2")); } } |