Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
{
"className": "org.jhotdraw.draw.figure.BDDRectangle.RoundRectangleFigureBDDTest",
"name": "Round Rectangle Figure BDD",
"scenarios": [
{
"className": "org.jhotdraw.draw.figure.BDDRectangle.RoundRectangleFigureBDDTest",
"testMethodName": "roundRectangle_resizes_when_bounds_are_set",
"description": "roundRectangle resizes when bounds are set",
"tagIds": [],
"explicitParameters": [],
"derivedParameters": [],
"scenarioCases": [
{
"caseNr": 1,
"steps": [
{
"name": "a round rectangle",
"words": [
{
"value": "Given",
"isIntroWord": true
},
{
"value": "a round rectangle"
}
],
"status": "PASSED",
"durationInNanos": 15482200,
"depth": 0,
"parentFailed": false
},
{
"name": "bounds are set",
"words": [
{
"value": "When",
"isIntroWord": true
},
{
"value": "bounds are set"
},
{
"value": "0.0",
"argumentInfo": {
"argumentName": "x1",
"formattedValue": "0.0"
}
},
{
"value": "0.0",
"argumentInfo": {
"argumentName": "y1",
"formattedValue": "0.0"
}
},
{
"value": "120.0",
"argumentInfo": {
"argumentName": "x2",
"formattedValue": "120.0"
}
},
{
"value": "60.0",
"argumentInfo": {
"argumentName": "y2",
"formattedValue": "60.0"
}
}
],
"status": "PASSED",
"durationInNanos": 12434500,
"depth": 0,
"parentFailed": false
},
{
"name": "round rectangle should have size",
"words": [
{
"value": "Then",
"isIntroWord": true
},
{
"value": "round rectangle should have size"
},
{
"value": "120.0",
"argumentInfo": {
"argumentName": "width",
"formattedValue": "120.0"
}
},
{
"value": "60.0",
"argumentInfo": {
"argumentName": "height",
"formattedValue": "60.0"
}
}
],
"status": "PASSED",
"durationInNanos": 158418700,
"depth": 0,
"parentFailed": false
}
],
"explicitArguments": [],
"derivedArguments": [],
"status": "SUCCESS",
"durationInNanos": 240078000
}
],
"casesAsTable": false,
"durationInNanos": 240078000
},
{
"className": "org.jhotdraw.draw.figure.BDDRectangle.RoundRectangleFigureBDDTest",
"testMethodName": "roundRectangle_arc_can_be_set",
"description": "roundRectangle arc can be set",
"tagIds": [],
"explicitParameters": [],
"derivedParameters": [],
"scenarioCases": [
{
"caseNr": 1,
"steps": [
{
"name": "a round rectangle",
"words": [
{
"value": "Given",
"isIntroWord": true
},
{
"value": "a round rectangle"
}
],
"status": "PASSED",
"durationInNanos": 328900,
"depth": 0,
"parentFailed": false
},
{
"name": "arc is set",
"words": [
{
"value": "When",
"isIntroWord": true
},
{
"value": "arc is set"
},
{
"value": "15.0",
"argumentInfo": {
"argumentName": "width",
"formattedValue": "15.0"
}
},
{
"value": "25.0",
"argumentInfo": {
"argumentName": "height",
"formattedValue": "25.0"
}
}
],
"status": "PASSED",
"durationInNanos": 2922000,
"depth": 0,
"parentFailed": false
},
{
"name": "round rectangle should have arc",
"words": [
{
"value": "Then",
"isIntroWord": true
},
{
"value": "round rectangle should have arc"
},
{
"value": "15.0",
"argumentInfo": {
"argumentName": "arcWidth",
"formattedValue": "15.0"
}
},
{
"value": "25.0",
"argumentInfo": {
"argumentName": "arcHeight",
"formattedValue": "25.0"
}
}
],
"status": "PASSED",
"durationInNanos": 1595900,
"depth": 0,
"parentFailed": false
}
],
"explicitArguments": [],
"derivedArguments": [],
"status": "SUCCESS",
"durationInNanos": 8337700
}
],
"casesAsTable": false,
"durationInNanos": 8337700
}
],
"tagMap": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jhotdraw.draw.figure.BDDRectangle;

import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.ProvidedScenarioState;
import org.jhotdraw.draw.figure.RoundRectangleFigure;


public class GivenRoundRectangle extends Stage<GivenRoundRectangle> {

@ProvidedScenarioState
RoundRectangleFigure roundRectangle;

public GivenRoundRectangle a_round_rectangle() {
roundRectangle = new RoundRectangleFigure();
return self();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.jhotdraw.draw.figure.BDDRectangle;

import com.tngtech.jgiven.junit5.ScenarioTest;
import org.junit.jupiter.api.Test;

public class RoundRectangleFigureBDDTest extends
ScenarioTest<GivenRoundRectangle, WhenSettingBounds, ThenRoundRectangle> {

@Test
public void roundRectangle_resizes_when_bounds_are_set() {
given().a_round_rectangle();
when().bounds_are_set(0, 0, 120, 60);
then().round_rectangle_should_have_size(120, 60);
}

@Test
public void roundRectangle_arc_can_be_set() {
given().a_round_rectangle();
when().arc_is_set(15, 25);
then().round_rectangle_should_have_arc(15, 25);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jhotdraw.draw.figure.BDDRectangle;

import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.ExpectedScenarioState;
import org.jhotdraw.draw.figure.RoundRectangleFigure;

import static org.assertj.core.api.Assertions.assertThat;

public class ThenRoundRectangle extends Stage<ThenRoundRectangle> {

@ExpectedScenarioState
RoundRectangleFigure roundRectangle;

public ThenRoundRectangle round_rectangle_should_have_size(double width, double height) {
assertThat(roundRectangle.getBounds().width).isEqualTo(width);
assertThat(roundRectangle.getBounds().height).isEqualTo(height);
return self();
}

public ThenRoundRectangle round_rectangle_should_have_arc(double arcWidth, double arcHeight) {
assertThat(roundRectangle.getArcWidth()).isEqualTo(arcWidth);
assertThat(roundRectangle.getArcHeight()).isEqualTo(arcHeight);
return self();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jhotdraw.draw.figure.BDDRectangle;


import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.ExpectedScenarioState;
import org.jhotdraw.draw.figure.RoundRectangleFigure;


import java.awt.geom.Point2D;

public class WhenSettingBounds extends Stage<WhenSettingBounds> {

@ExpectedScenarioState
RoundRectangleFigure roundRectangle;

public WhenSettingBounds bounds_are_set(double x1, double y1, double x2, double y2) {
roundRectangle.setBounds(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2));
return self();
}

public WhenSettingBounds arc_is_set(double width, double height) {
roundRectangle.setArc(width, height);
return self();
}
}
Loading