- Revision
- 647
- Author
- sirenian
- Date
- 2007-01-03 04:49:47 -0600 (Wed, 03 Jan 2007)
Log Message
[EK] Fixed hellbound outcomes so that outcomes with ambiguous names can take parameters showing the pit, and render those in story narration.
Modified Paths
- trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java
- trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java
- trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java
- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java
- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java
- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldFallOntoTheJunk.java
- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/HellboundScenario.java
- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java
- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java
Added Paths
Diff
Modified: trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java (646 => 647)
--- trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/core/src/behaviour/org/jbehave/core/story/renderer/PlainTextRendererBehaviour.java 2007-01-03 10:49:47 UTC (rev 647) @@ -46,7 +46,7 @@ PlainTextRenderer renderer = new PlainTextRenderer(printStream); - renderer.render("Custom renderable"); + renderer.renderAny("Custom renderable"); String result = byteStream.toString();
Modified: trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java (646 => 647)
--- trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/core/src/java/org/jbehave/core/story/renderer/PlainTextRenderer.java 2007-01-03 10:49:47 UTC (rev 647) @@ -84,7 +84,7 @@ out.println(phrase); } - public void render(Object obj) { + public void renderAny(Object obj) { out.println(obj.toString()); }
Modified: trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java (646 => 647)
--- trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/core/src/java/org/jbehave/core/story/renderer/Renderer.java 2007-01-03 10:49:47 UTC (rev 647) @@ -27,5 +27,5 @@ * This method can be used by scenario components overriding the * narrateTo method in order to render custom descriptions. */ - void render(Object obj); + void renderAny(Object obj); }
Modified: trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java (646 => 647)
--- trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/behaviour/com/sirenian/hellbound/gui/RenderedPit.java 2007-01-03 10:49:47 UTC (rev 647) @@ -17,7 +17,9 @@ public class RenderedPit extends Graphics { - private final int scale; + private static final String NL = System.getProperty("line.separator"); + + private final int scale; private Color color; private Map pitMap; private char[][] asciiRepresentation; @@ -148,9 +150,8 @@ public String toString() { StringBuffer buffer = new StringBuffer(); - buffer.append(System.getProperty("line.separator")); for (int i = 0; i < asciiRepresentation.length; i++) { - buffer.append(String.valueOf(asciiRepresentation[i])).append(System.getProperty("line.separator")); + buffer.append(String.valueOf(asciiRepresentation[i])).append(NL); } return buffer.toString(); }
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java (646 => 647)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/HellboundOutcome.java 2007-01-03 10:49:47 UTC (rev 647) @@ -17,6 +17,8 @@ public abstract class HellboundOutcome extends OutcomeUsingMiniMock { + protected static final String NL = System.getProperty("line.separator"); + protected static final Segments T_SHAPE_AT_TOP = new Segments( new Segment(2, 0), new Segment(3, 0), @@ -38,6 +40,18 @@ protected abstract void verifyAnyTimeIn(World world); + public Matcher looksLike(final String asciiRepresentation) { + return new Matcher() { + public boolean matches(Object arg) { + return ((RenderedPit)arg).toString().equals(asciiRepresentation); + } + + public String toString() { + return NL + asciiRepresentation; + } + }; + } + public Matcher contains(final Segments segments, final Color color) { return new Matcher() {
Added: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear.java (0 => 647)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear.java (rev 0) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear.java 2007-01-03 10:49:47 UTC (rev 647) @@ -0,0 +1,9 @@ +package com.sirenian.hellbound.outcomes; + +public class TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear extends ThePitShouldLookLike { + + public TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear(String expectedPit) { + super(expectedPit); + } + +}
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldFallOntoTheJunk.java (646 => 647)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldFallOntoTheJunk.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/TheGlyphShouldFallOntoTheJunk.java 2007-01-03 10:49:47 UTC (rev 647) @@ -1,9 +1,23 @@ package com.sirenian.hellbound.outcomes; -import org.jbehave.core.story.domain.World; -public class TheGlyphShouldFallOntoTheJunk extends HellboundOutcome { - protected void verifyAnyTimeIn(World world) { +public class TheGlyphShouldFallOntoTheJunk extends ThePitShouldLookLike { + + public TheGlyphShouldFallOntoTheJunk() { + super( + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "..ZZ..." + NL + + "...ZZ.." + NL + + "..XXX.." + NL + + "...X..." + NL); } }
Added: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/ThePitShouldLookLike.java (0 => 647)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/ThePitShouldLookLike.java (rev 0) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/outcomes/ThePitShouldLookLike.java 2007-01-03 10:49:47 UTC (rev 647) @@ -0,0 +1,25 @@ +package com.sirenian.hellbound.outcomes; + +import org.jbehave.core.Ensure; +import org.jbehave.core.story.domain.World; +import org.jbehave.core.story.renderer.Renderer; + +import com.sirenian.hellbound.gui.RenderedPit; + +public class ThePitShouldLookLike extends HellboundOutcome { + private final String expectedPit; + + public ThePitShouldLookLike(String expectedPit) { + this.expectedPit = expectedPit; + } + + public void verifyAnyTimeIn(World world) { + RenderedPit pit = getPit(world); + Ensure.that(pit, looksLike(expectedPit)); + } + + public void narrateTo(Renderer renderer) { + super.narrateTo(renderer); + renderer.renderAny(expectedPit); + } +}
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/HellboundScenario.java (646 => 647)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/HellboundScenario.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/HellboundScenario.java 2007-01-03 10:49:47 UTC (rev 647) @@ -4,4 +4,6 @@ public abstract class HellboundScenario extends MultiStepScenario { + protected static final String NL = System.getProperty("line.separator"); + }
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java (646 => 647)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphIntoAnEmptyPit.java 2007-01-03 10:49:47 UTC (rev 647) @@ -2,18 +2,30 @@ import com.sirenian.hellbound.events.ThePlayerPressesTheDropKey; import com.sirenian.hellbound.events.TimePasses; -import com.sirenian.hellbound.outcomes.TheGlyphSegmentsShouldBecomeJunk; +import com.sirenian.hellbound.outcomes.TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear; import com.sirenian.hellbound.outcomes.TheGlyphShouldFallToTheBottom; -import com.sirenian.hellbound.outcomes.TheNextGlyphShouldAppear; public class ThePlayerDropsTheGlyphIntoAnEmptyPit extends HellboundScenario { - + public void specifySteps() { given(new TheFirstGlyphIsDisplayedOnTheBoard()); when(new ThePlayerPressesTheDropKey()); then(new TheGlyphShouldFallToTheBottom()); when(new TimePasses()); - then(new TheGlyphSegmentsShouldBecomeJunk()); - then(new TheNextGlyphShouldAppear()); + then(new TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear( + "..ZZ..." + NL + + "...ZZ.." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "..XXX.." + NL + + "...X..." + NL + )); } }
Modified: trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java (646 => 647)
--- trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java 2007-01-02 17:24:13 UTC (rev 646) +++ trunk/examples/hellbound/src/stories/com/sirenian/hellbound/scenarios/ThePlayerDropsTheGlyphOntoJunk.java 2007-01-03 10:49:47 UTC (rev 647) @@ -1,9 +1,9 @@ package com.sirenian.hellbound.scenarios; import com.sirenian.hellbound.events.ThePlayerPressesTheDropKey; -import com.sirenian.hellbound.outcomes.TheGlyphSegmentsShouldBecomeJunk; +import com.sirenian.hellbound.events.TimePasses; +import com.sirenian.hellbound.outcomes.TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear; import com.sirenian.hellbound.outcomes.TheGlyphShouldFallOntoTheJunk; -import com.sirenian.hellbound.outcomes.TheNextGlyphShouldAppear; public class ThePlayerDropsTheGlyphOntoJunk extends HellboundScenario { @@ -11,7 +11,20 @@ given(new ThePlayerDropsTheGlyphIntoAnEmptyPit()); when(new ThePlayerPressesTheDropKey()); then(new TheGlyphShouldFallOntoTheJunk()); - then(new TheGlyphSegmentsShouldBecomeJunk()); - then(new TheNextGlyphShouldAppear()); + when(new TimePasses()); + then(new TheGlyphShouldBecomeJunkAndTheNextGlyphShouldAppear( + "...SS.." + NL + + "..SS..." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "......." + NL + + "..XX..." + NL + + "...XX.." + NL + + "..XXX.." + NL + + "...X..." + NL)); } }
To unsubscribe from this list please visit:
