- Revision
- 1496
- Author
- mauro
- Date
- 2010-01-05 08:46:33 -0600 (Tue, 05 Jan 2010)
Log Message
Removed Mockito deprecations.
Modified Paths
- trunk/core/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java
- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/ScenarioRunnerBehaviour.java
- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java
Diff
Modified: trunk/core/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java (1495 => 1496)
--- trunk/core/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java 2010-01-05 12:42:33 UTC (rev 1495) +++ trunk/core/examples/gameoflife/src/behaviour/com/lunivore/gameoflife/view/string/StringRendererBehaviour.java 2010-01-05 14:46:33 UTC (rev 1496) @@ -3,7 +3,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.jbehave.Ensure.ensureThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.stub; +import static org.mockito.Mockito.when; import org.junit.Test; @@ -17,9 +17,9 @@ public void shouldRenderCellsAsCrosses() { StringRenderer renderer = new StringRenderer(); Grid grid = mock(Grid.class); - stub(grid.getWidth()).toReturn(5); - stub(grid.getHeight()).toReturn(6); - stub(grid.hasLife(3, 4)).toReturn(true); + when(grid.getWidth()).thenReturn(5); + when(grid.getHeight()).thenReturn(6); + when(grid.hasLife(3, 4)).thenReturn(true); renderer.gridChanged(grid); ensureThat(renderer.asString(), equalTo(
Modified: trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/ScenarioRunnerBehaviour.java (1495 => 1496)
--- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2010-01-05 12:42:33 UTC (rev 1495) +++ trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/ScenarioRunnerBehaviour.java 2010-01-05 14:46:33 UTC (rev 1496) @@ -6,7 +6,7 @@ import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.stub; +import static org.mockito.Mockito.when; import static org.mockito.Mockito.verify; import java.util.HashMap; @@ -50,23 +50,23 @@ CandidateStep[] someCandidateSteps = new CandidateStep[0]; Step step = mock(Step.class); StepResult result = mock(StepResult.class); - stub(step.perform()).toReturn(result); + when(step.perform()).thenReturn(result); ScenarioReporter reporter = mock(ScenarioReporter.class); StepCreator creator = mock(StepCreator.class); CandidateSteps mySteps = mock(Steps.class); - stub(mySteps.getSteps()).toReturn(someCandidateSteps); + when(mySteps.getSteps()).thenReturn(someCandidateSteps); IllegalArgumentException anException = new IllegalArgumentException(); Step pendingStep = mock(Step.class); Step successfulStep = mock(Step.class); Step failingStep = mock(Step.class); - stub(pendingStep.perform()).toReturn(StepResult.pending("pendingStep")); - stub(successfulStep.perform()).toReturn(StepResult.success("successfulStep")); - stub(successfulStep.doNotPerform()).toReturn(StepResult.notPerformed("successfulStep")); - stub(failingStep.perform()).toReturn(StepResult.failure("failingStep", anException)); - stub(creator.createStepsFrom(scenarioDefinition1, tableRow, mySteps)).toReturn( + when(pendingStep.perform()).thenReturn(StepResult.pending("pendingStep")); + when(successfulStep.perform()).thenReturn(StepResult.success("successfulStep")); + when(successfulStep.doNotPerform()).thenReturn(StepResult.notPerformed("successfulStep")); + when(failingStep.perform()).thenReturn(StepResult.failure("failingStep", anException)); + when(creator.createStepsFrom(scenarioDefinition1, tableRow, mySteps)).thenReturn( new Step[] { failingStep, successfulStep }); - stub(creator.createStepsFrom(scenarioDefinition2, tableRow, mySteps)).toReturn(new Step[] { successfulStep }); - stub(creator.createStepsFrom(scenarioDefinition3, tableRow, mySteps)).toReturn( + when(creator.createStepsFrom(scenarioDefinition2, tableRow, mySteps)).thenReturn(new Step[] { successfulStep }); + when(creator.createStepsFrom(scenarioDefinition3, tableRow, mySteps)).thenReturn( new Step[] { successfulStep, pendingStep }); // When @@ -106,21 +106,21 @@ CandidateStep[] someCandidateSteps = new CandidateStep[0]; Step step = mock(Step.class); StepResult result = mock(StepResult.class); - stub(step.perform()).toReturn(result); + when(step.perform()).thenReturn(result); ScenarioDefiner scenarioDefiner = mock(ScenarioDefiner.class); ScenarioReporter reporter = mock(ScenarioReporter.class); StepCreator creator = mock(StepCreator.class); CandidateSteps mySteps = mock(Steps.class); - stub(mySteps.getSteps()).toReturn(someCandidateSteps); + when(mySteps.getSteps()).thenReturn(someCandidateSteps); Step successfulStep = mock(Step.class); - stub(successfulStep.perform()).toReturn(StepResult.success("successfulStep")); + when(successfulStep.perform()).thenReturn(StepResult.success("successfulStep")); Step anotherSuccessfulStep = mock(Step.class); - stub(anotherSuccessfulStep.perform()).toReturn(StepResult.success("anotherSuccessfulStep")); - stub(creator.createStepsFrom(scenarioDefinition1, tableRow, mySteps)).toReturn(new Step[] { successfulStep }); - stub(creator.createStepsFrom(scenarioDefinition2, tableRow, mySteps)).toReturn( + when(anotherSuccessfulStep.perform()).thenReturn(StepResult.success("anotherSuccessfulStep")); + when(creator.createStepsFrom(scenarioDefinition1, tableRow, mySteps)).thenReturn(new Step[] { successfulStep }); + when(creator.createStepsFrom(scenarioDefinition2, tableRow, mySteps)).thenReturn( new Step[] { anotherSuccessfulStep }); - stub(scenarioDefiner.loadScenarioDefinitionsFor("/path/to/given/scenario1")).toReturn(storyDefinition1); + when(scenarioDefiner.loadScenarioDefinitionsFor("/path/to/given/scenario1")).thenReturn(storyDefinition1); ErrorStrategy errorStrategy = mock(ErrorStrategy.class); // When @@ -148,12 +148,12 @@ Step fourthStepAlsoPending = mock(Step.class); StepCreator creator = mock(StepCreator.class); Steps mySteps = mock(Steps.class); - stub(creator.createStepsFrom((ScenarioDefinition) anyObject(), eq(tableRow), eq(mySteps))).toReturn( + when(creator.createStepsFrom((ScenarioDefinition) anyObject(), eq(tableRow), eq(mySteps))).thenReturn( new Step[] { firstStepNormal, secondStepPending, thirdStepNormal, fourthStepAlsoPending }); - stub(firstStepNormal.perform()).toReturn(StepResult.success("Given I succeed")); - stub(secondStepPending.perform()).toReturn(StepResult.pending("When I am pending")); - stub(thirdStepNormal.doNotPerform()).toReturn(StepResult.notPerformed("Then I should not be performed")); - stub(fourthStepAlsoPending.doNotPerform()).toReturn( + when(firstStepNormal.perform()).thenReturn(StepResult.success("Given I succeed")); + when(secondStepPending.perform()).thenReturn(StepResult.pending("When I am pending")); + when(thirdStepNormal.doNotPerform()).thenReturn(StepResult.notPerformed("Then I should not be performed")); + when(fourthStepAlsoPending.doNotPerform()).thenReturn( StepResult.notPerformed("Then I should not be performed either")); // When @@ -181,12 +181,12 @@ Step secondStepNotPerformed = mock(Step.class); StepResult failure = StepResult.failure("When I fail", new IllegalStateException()); StepResult notPerformed = StepResult.notPerformed("Then I should not be performed"); - stub(firstStepExceptional.perform()).toReturn(failure); - stub(secondStepNotPerformed.doNotPerform()).toReturn(notPerformed); + when(firstStepExceptional.perform()).thenReturn(failure); + when(secondStepNotPerformed.doNotPerform()).thenReturn(notPerformed); ErrorStrategy errorStrategy = mock(ErrorStrategy.class); StepCreator creator = mock(StepCreator.class); Steps mySteps = mock(Steps.class); - stub(creator.createStepsFrom((ScenarioDefinition) anyObject(), eq(tableRow), eq(mySteps))).toReturn( + when(creator.createStepsFrom((ScenarioDefinition) anyObject(), eq(tableRow), eq(mySteps))).thenReturn( new Step[] { firstStepExceptional, secondStepNotPerformed }); StoryDefinition story = new StoryDefinition(new ScenarioDefinition("")); boolean embeddedStory = false; @@ -215,14 +215,14 @@ ScenarioReporter reporter = mock(ScenarioReporter.class); Step pendingStep = mock(Step.class); Step secondStep = mock(Step.class); - stub(pendingStep.perform()).toReturn(StepResult.pending("pendingStep")); - stub(secondStep.perform()).toReturn(StepResult.success("secondStep")); + when(pendingStep.perform()).thenReturn(StepResult.pending("pendingStep")); + when(secondStep.perform()).thenReturn(StepResult.success("secondStep")); StepCreator creator = mock(StepCreator.class); CandidateSteps mySteps = mock(Steps.class); ScenarioDefinition scenario1 = mock(ScenarioDefinition.class); ScenarioDefinition scenario2 = mock(ScenarioDefinition.class); - stub(creator.createStepsFrom(scenario1, tableRow, mySteps)).toReturn(new Step[] { pendingStep }); - stub(creator.createStepsFrom(scenario2, tableRow, mySteps)).toReturn(new Step[] { secondStep }); + when(creator.createStepsFrom(scenario1, tableRow, mySteps)).thenReturn(new Step[] { pendingStep }); + when(creator.createStepsFrom(scenario2, tableRow, mySteps)).thenReturn(new Step[] { secondStep }); // When ScenarioRunner runner = new ScenarioRunner(); @@ -240,11 +240,11 @@ ScenarioReporter reporter = mock(ScenarioReporter.class); Step pendingStep = mock(Step.class); StepResult pendingResult = StepResult.pending("My step isn't defined!"); - stub(pendingStep.perform()).toReturn(pendingResult); + when(pendingStep.perform()).thenReturn(pendingResult); PendingErrorStrategy strategy = mock(PendingErrorStrategy.class); StepCreator creator = mock(StepCreator.class); Steps mySteps = mock(Steps.class); - stub(creator.createStepsFrom((ScenarioDefinition) anyObject(), eq(tableRow), eq(mySteps))).toReturn( + when(creator.createStepsFrom((ScenarioDefinition) anyObject(), eq(tableRow), eq(mySteps))).thenReturn( new Step[] { pendingStep }); // When
Modified: trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java (1495 => 1496)
--- trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java 2010-01-05 12:42:33 UTC (rev 1495) +++ trunk/core/jbehave-core/src/behaviour/java/org/jbehave/scenario/steps/UnmatchedToPendingStepCreatorBehaviour.java 2010-01-05 14:46:33 UTC (rev 1496) @@ -5,7 +5,7 @@ import static org.hamcrest.collection.IsArray.array; import static org.jbehave.Ensure.ensureThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.stub; +import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.HashMap; @@ -27,9 +27,9 @@ CandidateSteps steps = mock(Steps.class); Step executableStep = mock(Step.class); - stub(candidate.matches("my step")).toReturn(true); - stub(candidate.createFrom(tableRow, "my step")).toReturn(executableStep); - stub(steps.getSteps()).toReturn(new CandidateStep[] {candidate}); + when(candidate.matches("my step")).thenReturn(true); + when(candidate.createFrom(tableRow, "my step")).thenReturn(executableStep); + when(steps.getSteps()).thenReturn(new CandidateStep[] {candidate}); // When Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableRow, steps); @@ -47,8 +47,8 @@ CandidateStep candidate = mock(CandidateStep.class); CandidateSteps steps = mock(Steps.class); - stub(candidate.matches("my step")).toReturn(false); - stub(steps.getSteps()).toReturn(new CandidateStep[] {candidate}); + when(candidate.matches("my step")).thenReturn(false); + when(steps.getSteps()).thenReturn(new CandidateStep[] {candidate}); // When Step[] executableSteps = creator.createStepsFrom(new ScenarioDefinition("", asList("my step")), tableRow, steps); @@ -69,19 +69,19 @@ Step stepAfter1 = mock(Step.class); Step stepAfter2 = mock(Step.class); - stub(steps1.runBeforeScenario()).toReturn(Arrays.asList(stepBefore1)); - stub(steps2.runBeforeScenario()).toReturn(Arrays.asList(stepBefore2)); - stub(steps1.runAfterScenario()).toReturn(Arrays.asList(stepAfter1)); - stub(steps2.runAfterScenario()).toReturn(Arrays.asList(stepAfter2)); + when(steps1.runBeforeScenario()).thenReturn(Arrays.asList(stepBefore1)); + when(steps2.runBeforeScenario()).thenReturn(Arrays.asList(stepBefore2)); + when(steps1.runAfterScenario()).thenReturn(Arrays.asList(stepAfter1)); + when(steps2.runAfterScenario()).thenReturn(Arrays.asList(stepAfter2)); // And which have a 'normal' step that matches our scenario CandidateStep candidate = mock(CandidateStep.class); Step normalStep = mock(Step.class); - stub(candidate.matches("my step")).toReturn(true); - stub(candidate.createFrom(tableRow, "my step")).toReturn(normalStep); - stub(steps1.getSteps()).toReturn(new CandidateStep[] {candidate}); - stub(steps2.getSteps()).toReturn(new CandidateStep[] {}); + when(candidate.matches("my step")).thenReturn(true); + when(candidate.createFrom(tableRow, "my step")).thenReturn(normalStep); + when(steps1.getSteps()).thenReturn(new CandidateStep[] {candidate}); + when(steps2.getSteps()).thenReturn(new CandidateStep[] {}); // When we create the series of steps for the scenario UnmatchedToPendingStepCreator creator = new UnmatchedToPendingStepCreator();
To unsubscribe from this list please visit:
