- Revision
- 1231
- Author
- mauro
- Date
- 2009-09-07 16:32:40 -0500 (Mon, 07 Sep 2009)
Log Message
Renamed Table to ExamplesTable.
Modified Paths
- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java
- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/parser/PatternScenarioParserBehaviour.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/ScenarioDefinition.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords.properties
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es_ES.properties
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/parser/PatternScenarioParser.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java
- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java
Added Paths
Removed Paths
Diff
Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario (1230 => 1231)
--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario 2009-09-07 21:32:40 UTC (rev 1231) @@ -5,7 +5,7 @@ Given a stock of symbol STK1 and a threshold of 15.0 When the stock is traded at price 5.0 -Then the alert status should be OFF +Then the alert status is OFF When the stock is sold at price 11.0 Then the alert status is OFF When the stock is sold at price 16.0
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java (1230 => 1231)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/i18n/I18nKeywordsBehaviour.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -15,7 +15,7 @@ KeyWords keywords = new I18nKeyWords(); assertEquals("Scenario:", keywords.scenario()); assertEquals("GivenScenarios:", keywords.givenScenarios()); - assertEquals("Examples:", keywords.table()); + assertEquals("Examples:", keywords.examplesTable()); assertEquals("Given", keywords.given()); assertEquals("When", keywords.when()); assertEquals("Then", keywords.then()); @@ -26,9 +26,9 @@ public void keywordsInItalian(){ KeyWords keywords = new I18nKeyWords(Locale.ITALIAN); assertEquals("Scenario:", keywords.scenario()); - assertEquals("DatiScenari:", keywords.givenScenarios()); - assertEquals("Esempi:", keywords.table()); - assertEquals("Dato", keywords.given()); + assertEquals("Dati gli Scenari:", keywords.givenScenarios()); + assertEquals("Esempi:", keywords.examplesTable()); + assertEquals("Dato che", keywords.given()); assertEquals("Quando", keywords.when()); assertEquals("Allora", keywords.then()); assertEquals("E", keywords.and()); @@ -38,9 +38,9 @@ public void keywordsInSpanish(){ KeyWords keywords = new I18nKeyWords(new Locale("es", "ES", "")); assertEquals("Escenario:", keywords.scenario()); - assertEquals("DadosEscenarios:", keywords.givenScenarios()); - assertEquals("Ejemplos:", keywords.table()); - assertEquals("Dado", keywords.given()); + assertEquals("Dados los Escenarios:", keywords.givenScenarios()); + assertEquals("Ejemplos:", keywords.examplesTable()); + assertEquals("Dado que", keywords.given()); assertEquals("Cuando", keywords.when()); assertEquals("Entonces", keywords.then()); assertEquals("Y", keywords.and());
Modified: trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/parser/PatternScenarioParserBehaviour.java (1230 => 1231)
--- trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/parser/PatternScenarioParserBehaviour.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/behaviour/org/jbehave/scenario/parser/PatternScenarioParserBehaviour.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -11,7 +11,7 @@ import org.jbehave.scenario.PropertyBasedConfiguration; import org.jbehave.scenario.definition.ScenarioDefinition; import org.jbehave.scenario.definition.StoryDefinition; -import org.jbehave.scenario.definition.Table; +import org.jbehave.scenario.definition.ExamplesTable; import org.junit.Ignore; import org.junit.Test; @@ -218,7 +218,7 @@ "When I run the scenario of name <two>", "Then I should see <three> in the output" ))); - Table table = scenario.getTable(); + ExamplesTable table = scenario.getTable(); ensureThat(table.toString(), equalTo( "|one|two|three|" + NL + "|a|b|c|" + NL +
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/ScenarioRunner.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -6,7 +6,7 @@ import org.jbehave.scenario.definition.ScenarioDefinition; import org.jbehave.scenario.definition.StoryDefinition; -import org.jbehave.scenario.definition.Table; +import org.jbehave.scenario.definition.ExamplesTable; import org.jbehave.scenario.errors.ErrorStrategy; import org.jbehave.scenario.errors.PendingError; import org.jbehave.scenario.errors.PendingErrorStrategy; @@ -63,14 +63,14 @@ } private boolean isTemplateScenario(ScenarioDefinition scenario) { - Table table = scenario.getTable(); + ExamplesTable table = scenario.getTable(); return table != null && table.getRowCount() > 0; } private void runTemplateScenario(Configuration configuration, - ScenarioDefinition scenario, Table table, + ScenarioDefinition scenario, ExamplesTable table, CandidateSteps... candidateSteps) { - reporter.usingTable(table); + reporter.usingExamplesTable(table); for (Map<String,String> tableRow : table.getRows() ) { reporter.usingTableRow(tableRow); runScenario(configuration, scenario, tableRow, candidateSteps);
Copied: trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/ExamplesTable.java (from rev 1228, trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/Table.java) (0 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/ExamplesTable.java (rev 0) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/ExamplesTable.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -0,0 +1,74 @@ +package org.jbehave.scenario.definition; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Represents a tabular structure to hold example data for number of named parameters:<br/><br/> + * + * |name 1|name 2| .... |name n|<br/> + * |value 11|value 12| .... |value 1n|<br/> + * ...<br/> + * |value m1|value m2| .... |value mn|<br/> + */ +public class ExamplesTable { + + private static final String COLUMN_SEPARATOR = "\\|"; + private final List<Map<String, String>> data = "" ArrayList<Map<String, String>>(); + private final String tableAsString; + + public ExamplesTable(String tableAsString) { + this.tableAsString = tableAsString; + parse(); + } + + private void parse() { + data.clear(); + String[] rows = tableAsString.split("\n"); + List<String> headers = new ArrayList<String>(); + for (int row = 0; row < rows.length; row++) { + List<String> columns = columnsFor(rows[row]); + if ( row == 0 ) { + headers.addAll(columns); + } else { + Map<String, String> map = new HashMap<String, String>(); + for ( int column = 0; column < columns.size(); column++ ){ + map.put(headers.get(column), columns.get(column)); + } + data.add(map); + } + } + } + + private List<String> columnsFor(String row) { + List<String> columns = new ArrayList<String>(); + for ( String column : row.split(COLUMN_SEPARATOR) ){ + columns.add(column.trim()); + } + int size = columns.size(); + if ( size > 0 ){ + columns.remove(0); + } + return columns; + } + + public Map<String, String> getRow(int row){ + return data.get(row); + } + + public int getRowCount(){ + return data.size(); + } + + public List<Map<String, String>> getRows() { + return data; + } + + @Override + public String toString(){ + return tableAsString; + } + +}
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/KeyWords.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -17,27 +17,27 @@ static final String WHEN = "When"; static final String THEN = "Then"; static final String AND = "And"; - static final String TABLE = "Table"; - protected static final List<String> KEYWORDS = Arrays.asList(SCENARIO, GIVEN_SCENARIOS, GIVEN, WHEN, THEN, AND, TABLE); + static final String EXAMPLES_TABLE = "ExamplesTable"; + protected static final List<String> KEYWORDS = Arrays.asList(SCENARIO, GIVEN_SCENARIOS, GIVEN, WHEN, THEN, AND, EXAMPLES_TABLE); private final String scenario; private final String givenScenarios; private final String given; private final String when; private final String then; - private final String table; + private final String examplesTable; private final String[] others; public KeyWords(Map<String, String> keywords) { this(keywords.get(SCENARIO), keywords.get(GIVEN_SCENARIOS), keywords - .get(TABLE), keywords.get(GIVEN), keywords.get(WHEN), keywords.get(THEN), keywords.get(AND)); + .get(EXAMPLES_TABLE), keywords.get(GIVEN), keywords.get(WHEN), keywords.get(THEN), keywords.get(AND)); } - public KeyWords(String scenario, String givenScenarios, String table, + public KeyWords(String scenario, String givenScenarios, String examplesTable, String given, String when, String then, String... others) { this.scenario = scenario; this.givenScenarios = givenScenarios; - this.table = table; + this.examplesTable = examplesTable; this.given = given; this.when = when; this.then = then; @@ -52,8 +52,8 @@ return givenScenarios; } - public String table() { - return table; + public String examplesTable() { + return examplesTable; } public String given() {
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/ScenarioDefinition.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/ScenarioDefinition.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/ScenarioDefinition.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -10,7 +10,7 @@ private final String title; private final List<String> givenScenarios; private final List<String> steps; - private final Table table; + private final ExamplesTable table; public ScenarioDefinition(String title) { this("", new ArrayList<String>()); @@ -21,21 +21,21 @@ } public ScenarioDefinition(String title, List<String> steps) { - this(title, new ArrayList<String>(), new Table(""), steps); + this(title, new ArrayList<String>(), new ExamplesTable(""), steps); } public ScenarioDefinition(String title, List<String> givenScenarios, List<String> steps) { - this(title, givenScenarios, new Table(""), steps); + this(title, givenScenarios, new ExamplesTable(""), steps); } - public ScenarioDefinition(String title, List<String> givenScenarios, Table table, List<String> steps) { + public ScenarioDefinition(String title, List<String> givenScenarios, ExamplesTable table, List<String> steps) { this.title = title; this.givenScenarios = givenScenarios; this.steps = steps; this.table = table; } - public ScenarioDefinition(String title, Table table, String... steps) { + public ScenarioDefinition(String title, ExamplesTable table, String... steps) { this(title, new ArrayList<String>(), table, asList(steps)); } @@ -51,7 +51,7 @@ return title; } - public Table getTable(){ + public ExamplesTable getTable(){ return table; }
Deleted: trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/Table.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/Table.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/definition/Table.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -1,74 +0,0 @@ -package org.jbehave.scenario.definition; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Represents a tabular structure:<br/><br/> - * - * |header 1|header 2| .... |header n|<br/> - * |value 11|value 12| .... |value 1n|<br/> - * ...<br/> - * |value m1|value m2| .... |value mn|<br/> - */ -public class Table { - - private static final String COLUMN_SEPARATOR = "\\|"; - private final List<Map<String, String>> data = "" ArrayList<Map<String, String>>(); - private final String tableAsString; - - public Table(String tableAsString) { - this.tableAsString = tableAsString; - parse(); - } - - private void parse() { - data.clear(); - String[] rows = tableAsString.split("\n"); - List<String> headers = new ArrayList<String>(); - for (int row = 0; row < rows.length; row++) { - List<String> columns = columnsFor(rows[row]); - if ( row == 0 ) { - headers.addAll(columns); - } else { - Map<String, String> map = new HashMap<String, String>(); - for ( int column = 0; column < columns.size(); column++ ){ - map.put(headers.get(column), columns.get(column)); - } - data.add(map); - } - } - } - - private List<String> columnsFor(String row) { - List<String> columns = new ArrayList<String>(); - for ( String column : row.split(COLUMN_SEPARATOR) ){ - columns.add(column.trim()); - } - int size = columns.size(); - if ( size > 0 ){ - columns.remove(0); - } - return columns; - } - - public Map<String, String> getRow(int row){ - return data.get(row); - } - - public int getRowCount(){ - return data.size(); - } - - public List<Map<String, String>> getRows() { - return data; - } - - @Override - public String toString(){ - return tableAsString; - } - -}
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords.properties (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords.properties 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords.properties 2009-09-07 21:32:40 UTC (rev 1231) @@ -1,6 +1,6 @@ Scenario=Scenario: GivenScenarios=GivenScenarios: -Table=Examples: +ExamplesTable=Examples: Given=Given When=When Then=Then
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es_ES.properties (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es_ES.properties 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_es_ES.properties 2009-09-07 21:32:40 UTC (rev 1231) @@ -1,7 +1,7 @@ Scenario=Escenario: -GivenScenarios=DadosEscenarios: -Table=Ejemplos: -Given=Dado +GivenScenarios=Dados los Escenarios: +ExamplesTable=Ejemplos: +Given=Dado que When=Cuando Then=Entonces And=Y
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/i18n/keywords_it.properties 2009-09-07 21:32:40 UTC (rev 1231) @@ -1,7 +1,7 @@ Scenario=Scenario: -GivenScenarios=DatiScenari: -Table=Esempi: -Given=Dato +GivenScenarios=Dati gli Scenari: +ExamplesTable=Esempi: +Given=Dato che When=Quando Then=Allora And=E
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/parser/PatternScenarioParser.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/parser/PatternScenarioParser.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/parser/PatternScenarioParser.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -14,7 +14,7 @@ import org.jbehave.scenario.definition.KeyWords; import org.jbehave.scenario.definition.ScenarioDefinition; import org.jbehave.scenario.definition.StoryDefinition; -import org.jbehave.scenario.definition.Table; +import org.jbehave.scenario.definition.ExamplesTable; /** * Pattern-based scenario parser, which uses the configured keywords to find the @@ -46,7 +46,7 @@ List<String> scenarios = splitScenarios(wholeStoryAsString); for (String scenario : scenarios) { String title = findTitle(scenario); - Table table = findTable(scenario); + ExamplesTable table = findTable(scenario); List<String> givenScenarios = findGivenScenarios(scenario); List<String> steps = findSteps(scenario); scenarioDefinitions @@ -61,11 +61,11 @@ return findingTitle.find() ? findingTitle.group(1).trim() : NONE; } - private Table findTable(String scenario) { + private ExamplesTable findTable(String scenario) { Matcher findingTable = patternToPullScenarioTableIntoGroupOne() .matcher(scenario); String table = findingTable.find() ? findingTable.group(1).trim() : NONE; - return new Table(table); + return new ExamplesTable(table); } private List<String> findGivenScenarios(String scenario) { @@ -178,7 +178,7 @@ private Pattern patternToPullScenarioTableIntoGroupOne() { KeyWords keywords = configuration.keywords(); - String table = keywords.table(); + String table = keywords.examplesTable(); return compile(".*"+table+"\\s*((.|\\s)*)"); } @@ -235,7 +235,7 @@ String givenWhenThenSpaced = concatenateWithSpaceOr(keywords.given(), keywords.when(), keywords.then(), keywords.others()); String scenario = keywords.scenario(); - String table = keywords.table(); + String table = keywords.examplesTable(); return compile("((" + givenWhenThen + ") (.|\\s)*?)\\s*(\\Z|" + givenWhenThenSpaced + "|" + scenario + "|"+ table + ")"); }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PassSilentlyDecorator.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -5,7 +5,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; -import org.jbehave.scenario.definition.Table; +import org.jbehave.scenario.definition.ExamplesTable; /** * Swallows the reports from all scenarios that pass, providing output only for @@ -114,10 +114,10 @@ }); } - public void usingTable(final Table table) { + public void usingExamplesTable(final ExamplesTable table) { currentScenario.add(new Todo() { public void doNow() { - delegate.usingTable(table); + delegate.usingExamplesTable(table); } }); }
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/PrintStreamScenarioReporter.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -5,7 +5,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; -import org.jbehave.scenario.definition.Table; +import org.jbehave.scenario.definition.ExamplesTable; /** * <p> @@ -75,8 +75,8 @@ output.println("GivenScenarios: " + givenScenarios); } - public void usingTable(Table table) { - output.println("Using table:"); + public void usingExamplesTable(ExamplesTable table) { + output.println("Using examples table:"); output.println(); output.println(table); output.println();
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/ScenarioReporter.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -4,7 +4,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; -import org.jbehave.scenario.definition.Table; +import org.jbehave.scenario.definition.ExamplesTable; /** * Allows the runner to report the state of running scenarios @@ -24,7 +24,7 @@ void givenScenarios(List<String> givenScenarios); - void usingTable(Table table); + void usingExamplesTable(ExamplesTable table); void usingTableRow(Map<String, String> tableRow);
Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java (1230 => 1231)
--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-09-07 21:07:27 UTC (rev 1230) +++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/reporters/StepFailureScenarioReporterDecorator.java 2009-09-07 21:32:40 UTC (rev 1231) @@ -4,7 +4,7 @@ import java.util.Map; import org.jbehave.scenario.definition.Blurb; -import org.jbehave.scenario.definition.Table; +import org.jbehave.scenario.definition.ExamplesTable; import org.jbehave.scenario.errors.StepFailure; /** @@ -67,8 +67,8 @@ delegate.givenScenarios(givenScenarios); } - public void usingTable(Table table) { - delegate.usingTable(table); + public void usingExamplesTable(ExamplesTable table) { + delegate.usingExamplesTable(table); } public void usingTableRow(Map<String, String> tableRow) {
To unsubscribe from this list please visit:
