Skip to content

Commit

Permalink
new bdd test #1
Browse files Browse the repository at this point in the history
  • Loading branch information
amurlamur committed May 18, 2024
1 parent b799777 commit d11d373
Show file tree
Hide file tree
Showing 22 changed files with 174 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/main/java/program/main/NomadPipeInteraction.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ public static boolean getendturn(){
public static void setendturn(boolean temp){
endturn = temp;
}

public Object getSlippery() {
return slippery;
}

public Object getEnd() {
return end;
}
}
8 changes: 8 additions & 0 deletions src/main/java/program/main/PlumberPipeInteraction.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ public Object getSticky() {
}

public Object getDestroy() {return destroy;}

public Object getRepair(){
return repair;
}

public Object getEnd() {
return end;
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/stepDefinition/UIChangePipeIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class UIChangePipeIn {
private PlumberPipeInWindow ppWindow = new PlumberPipeInWindow(3);
@When("click on change pipe in")
public void click_on_change_pipe_in() {
System.out.println("changing pipe in");
System.out.println("test started");
ActionEvent event = new ActionEvent(pbPanel.getChangePipeIn(), ActionEvent.ACTION_PERFORMED, "change pipe in");
pbPanel.actionPerformed(event);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/stepDefinition/UIChangePipeOut.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class UIChangePipeOut {
private PlumberPipeOutWindow ppWindow = new PlumberPipeOutWindow(3);
@When("click on change pipe out")
public void click_on_change_pipe_out() {
System.out.println("changing pipe out");
System.out.println("test started");
ActionEvent event = new ActionEvent(pbPanel.getChangePipeOut(), ActionEvent.ACTION_PERFORMED, "change pipe out");
pbPanel.actionPerformed(event);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/stepDefinition/UIDestroyPipeSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class UIDestroyPipeSteps {

@When("click on destroy pipe")
public void click_on_destroy_pipe() {
System.out.println("destroying pipe");
System.out.println("test started");
ActionEvent event = new ActionEvent(ppInteraction.getDestroy(), ActionEvent.ACTION_PERFORMED, "destroy");
ppInteraction.actionPerformed(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import program.main.Pipe;
import program.main.PlumberPipeInteraction;

import static org.junit.Assert.assertEquals;
Expand All @@ -11,7 +10,7 @@

import java.awt.event.ActionEvent;

public class UIMakePipeStickSteps {
public class UIMakePipeStickySteps {

private PlumberPipeInteraction ppInteraction = new PlumberPipeInteraction();
@When("click on make sticky")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.stepDefinition;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import program.main.NomadMoveWindow;
import program.main.NomadPipeInteraction;
import program.main.PlumberMoveWindow;
import program.main.PlumberPipeInteraction;

import java.awt.event.ActionEvent;

import static org.junit.Assert.assertTrue;
import static program.main.Main.game;

public class UINomadMakesPipeSlipperySteps {
private NomadPipeInteraction npInteraction = new NomadPipeInteraction();
private NomadMoveWindow nmWindow = new NomadMoveWindow(3);

@When("select destination nomad")
public void select_destination_nomad() {
System.out.println("test started");
nmWindow.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"pump4"));
}
@When("click on make slippery")
public void click_on_make_slippery() {
System.out.println("test started");
ActionEvent endButtonEvent = new ActionEvent(npInteraction.getSlippery(), ActionEvent.ACTION_PERFORMED, "slippery");
npInteraction.actionPerformed(endButtonEvent);
}
@When("click on end turn nomad")
public void click_on_end_turn_nomad() {
System.out.println("test started");
ActionEvent endButtonEvent = new ActionEvent(npInteraction.getEnd(), ActionEvent.ACTION_PERFORMED, "end");
npInteraction.actionPerformed(endButtonEvent);
}
@Then("check if the pipe is slippery")
public void check_if_the_pipe_is_slippery() {
System.out.println("test started");
assertTrue(game.Pipes().get(2).GetSlippery());
}
}
6 changes: 4 additions & 2 deletions src/test/java/com/stepDefinition/UIPlumberMovesSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
public class UIPlumberMovesSteps {
private PlumberButtonPanel pbPanel = new PlumberButtonPanel();
private PlumberMoveWindow pmWindow = new PlumberMoveWindow(3);

private PlumberPipeInteraction ppInteraction = new PlumberPipeInteraction();
@When("click on move button")
public void click_on_move_button() {
System.out.println("test started");
Expand All @@ -35,8 +37,8 @@ public void select_destination() {
@When("click on end turn")
public void click_on_end_turn() {
System.out.println("test started");
ActionEvent endButtonEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "end");
new PlumberPipeInteraction().actionPerformed(endButtonEvent);
ActionEvent endButtonEvent = new ActionEvent(ppInteraction.getEnd(), ActionEvent.ACTION_PERFORMED, "end");
ppInteraction.actionPerformed(endButtonEvent);
}
@Then("check new position")
public void check_new_position() {
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/com/stepDefinition/UIRepairBrokenPipeSteps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.stepDefinition;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import program.main.PlumberPipeInteraction;
import program.main.State;

import java.awt.event.ActionEvent;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static program.main.Main.game;

public class UIRepairBrokenPipeSteps {
private PlumberPipeInteraction ppInteraction = new PlumberPipeInteraction();
@When("click on repair pipe")
public void click_on_repair_pipe() {
System.out.println("test started");
ActionEvent endButtonEvent = new ActionEvent(ppInteraction.getRepair(), ActionEvent.ACTION_PERFORMED, "repair");
ppInteraction.actionPerformed(endButtonEvent);
}
@Then("test if pipe is fixed")
public void test_if_pipe_is_fixed() {
System.out.println("test started");
assertEquals(game.Pipes().get(3).getState(), State.Working);
}
}
24 changes: 24 additions & 0 deletions src/test/resources/Features/UINomadMakesPipeSlippery.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature: Nomad makes pipe slippery.

Scenario: First the plumbers move, then nomad stands on a pump then moves to the other pump and makes the pipe between them slippery.

Given game window starts
When click on start
And game starts
And click on move button
And select destination
And click on end turn
And click on move button
And select destination
And click on end turn
And click on move button
And select destination
And click on end turn
And click on move button
And select destination
And click on end turn
And click on move button
And select destination nomad
And click on make slippery
And click on end turn nomad
Then check if the pipe is slippery
17 changes: 17 additions & 0 deletions src/test/resources/Features/UIRepairBrokenPipe.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Tests a plumber repairing a pipe.

Scenario: A plumber moves from the starting pump to a neighboring one, and destroys the pipe in-between, then an other plumber moves and repairs that pipe.

Given game window starts
When click on start
And game starts
And click on move button
And select destination
And click on destroy pipe
And click on end turn
And test if pipe is broken
And click on move button
And select destination
And click on repair pipe
And click on end turn
Then test if pipe is fixed
Binary file modified target/classes/program/main/NomadPipeInteraction.class
Binary file not shown.
Binary file modified target/classes/program/main/PlumberPipeInteraction.class
Binary file not shown.
24 changes: 24 additions & 0 deletions target/test-classes/Features/UINomadMakesPipeSlippery.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature: Nomad makes pipe slippery.

Scenario: First the plumbers move, then nomad stands on a pump then moves to the other pump and makes the pipe between them slippery.

Given game window starts
When click on start
And game starts
And click on move button
And select destination
And click on end turn
And click on move button
And select destination
And click on end turn
And click on move button
And select destination
And click on end turn
And click on move button
And select destination
And click on end turn
And click on move button
And select destination nomad
And click on make slippery
And click on end turn nomad
Then check if the pipe is slippery
17 changes: 17 additions & 0 deletions target/test-classes/Features/UIRepairBrokenPipe.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Tests a plumber repairing a pipe.

Scenario: A plumber moves from the starting pump to a neighboring one, and destroys the pipe in-between, then an other plumber moves and repairs that pipe.

Given game window starts
When click on start
And game starts
And click on move button
And select destination
And click on destroy pipe
And click on end turn
And test if pipe is broken
And click on move button
And select destination
And click on repair pipe
And click on end turn
Then test if pipe is fixed
Binary file modified target/test-classes/com/stepDefinition/UIChangePipeIn.class
Binary file not shown.
Binary file modified target/test-classes/com/stepDefinition/UIChangePipeOut.class
Binary file not shown.
Binary file modified target/test-classes/com/stepDefinition/UIDestroyPipeSteps.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified target/test-classes/com/stepDefinition/UIPlumberMovesSteps.class
Binary file not shown.
Binary file not shown.

0 comments on commit d11d373

Please sign in to comment.