Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #367

Open
wants to merge 39 commits into
base: continuous-delivery
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c97a9ec
Update gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Ce…
VisionMaverick May 9, 2012
f9e7ba5
Merge pull request #7 from virendray/patch-1
wakaleo Mar 5, 2013
7925e7c
Merge pull request #13 from VDD/continuous-delivery
wakaleo Mar 5, 2013
118e088
Restored working tests
wakaleo Apr 12, 2013
168975f
Updated the jacoco plugin
wakaleo Nov 19, 2013
1e90fa9
Updated dependencies
wakaleo Sep 16, 2014
0c4b7af
Updated dependencies
wakaleo Sep 16, 2014
1805132
Merge branch 'master' of github.com:wakaleo/game-of-life
wakaleo Sep 16, 2014
6b21916
fix for 'mvn jetty:run' per https://github.com/wakaleo/game-of-life/i…
schottsfired Sep 16, 2016
6fa646e
add Dockerfile
schottsfired Sep 17, 2016
6ebd401
update default URLs, bump Thucydides version
schottsfired Sep 17, 2016
d61593f
gameoflife.war must run standalone
schottsfired Sep 18, 2016
238ed9c
move Selenium Dockerfile
schottsfired Sep 18, 2016
ce7a834
Merge pull request #123 from shott85/master
wakaleo Sep 18, 2016
2a99026
Added function explanations for controller classes
LuuKhang Mar 9, 2017
d96be23
Added function explanations for grid, cell, and related classes
LuuKhang Mar 9, 2017
c3f5796
Merge pull request #143 from LuuKhang/documentation
wakaleo Mar 9, 2017
a514910
Commit
Jun 24, 2017
1406a96
Commit
Jun 24, 2017
d4e03f2
Updated dependencies
wakaleo Dec 4, 2017
9717b42
Serenity version 1.8.3 missing from Maven repo so changed it to 1.8.4
GeraldScott Jan 27, 2018
af6563c
Change live cell to @ and dead cell :
Jan 27, 2018
5106dd9
Revert live cell and dead cell
Jan 27, 2018
dd4ff8c
Change Thucydides to Serenity
GeraldScott Jan 27, 2018
be3c254
Edit for clarity
GeraldScott Jan 27, 2018
c24bb1a
Merge pull request #198 from GeraldScott/master
wakaleo Jan 27, 2018
695d6de
Update README.markdown
pranaygupta5 Apr 28, 2022
7e1e076
pushing .github folder
May 2, 2022
26b18a7
Merge branch 'continuous-delivery' of https://github.com/pranaygupta5…
May 4, 2022
9610b96
Adding .github folder
May 4, 2022
789e354
Adding .github folder
May 4, 2022
b042c4b
Merge branch 'master' into continuous-delivery
May 4, 2022
acc6d47
Adding .github folder
May 4, 2022
4d9069a
Adding .github folder
May 4, 2022
7493bc8
Adding file
May 5, 2022
b976a7e
Adding file
May 6, 2022
73db75d
Merge branch 'wakaleo:master' into master
pranaygupta5 Dec 27, 2022
ff83a94
Merge branch 'master' into continuous-delivery
Dec 27, 2022
14a2d66
fix(platform): wre-458-testing
Dec 27, 2022
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
9 changes: 9 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://gecgithub01.walmart.com/mobile-platform/github-app-monolith
# https://github.com/probot/stale#usage
daysUntilStale: 1
daysUntilClose: 2
staleLabel: stale
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
15 changes: 15 additions & 0 deletions .github/walmart-probot-buddy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const config = {
admin_users: ["pranaygupta5"], // this is owner of the repository we are going to add the bot
merge_user: "pranaygupta5", // this can be same as the admin any one can merge
enabled_features: [
"autolabeler",
"bot-pr-merge",
"semantic-pull-requests",
"stalebot",
"merge-queue",
"stale-branch-bot",
"sync-base-branch"
],
add_pr_label:"foo",
sync_base_branch_on_changed_files_intersect:["^libs\/.*\/src\/","^apps\/.*\/app\/"]
}
10 changes: 6 additions & 4 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ This is a simple demonstration application used in the [Jenkins: The Definitive

The project is a simple multi-module Maven project. To build the whole project, just run `mvn install` from the root directory.

## Running the game
## Running the game1

The application is a very simple online version of [Conway's 'game of life'](http://en.wikipedia.org/wiki/Conway's_Game_of_Life). To see what the game does, run `mvn install` as described above, thengo to the gameoflife-web directory and run `mvn jetty:run`. The application will be running on http://localhost:9090.
The application is a very simple online version of [Conway's 'game of life'](http://en.wikipedia.org/wiki/Conway's_Game_of_Life). To see what the game does, run `mvn install` as described above, then go to the gameoflife-web directory and run `mvn jetty:run`. The application will be running on http://localhost:9090.

## Running the acceptance tests

The acceptance tests are written using Webdriver and [Thucydides](http://thucydides.info). They are designed to run against a running server. Run the jetty instance as described about, then, in another window, go to the gameoflife-acceptance-tests directory and run `mvn clean verify`. The test reports will be generated in the `target/site/thucydides` directory.
The acceptance tests are written using Webdriver and [Serenity (previously known as 'Thucydides')](http://thucydides.info). They are designed to run against a running server. Run the jetty instance as described about, then, in another window, go to the gameoflife-acceptance-tests directory and run `mvn clean verify`. The test reports will be generated in the `target/site/thucydides` directory.

## The book

Expand All @@ -26,6 +26,8 @@ Ideal for developers, software architects, and project managers, Jenkins: The De
- Manage a farm of Jenkins servers to run distributed builds
- Implement automated deployment and continuous delivery

## The author
## The author1

John is an experienced consultant and trainer specialising in Enterprise Java, Web Development, and Open Source technologies, based in Sydney, Australia. Well known in the Java community for his many published articles, and as author of Java Power Tools, John helps organisations around the world to optimize their Java development processes and infrastructures and provides training and mentoring in open source technologies, SDLC tools, and agile development processes. John is CEO of [Wakaleo Consulting](http://www.wakaleo.com), a company that provides consulting, training and mentoring services in Enterprise Java and Agile Development. He is also part of the founding team of [Test Automation](http://www.testautomation.com.au/), a service that automates the manual regression tests conducted during the integration and acceptance testing stages of a web site release.
## Creating the PR
# testing
22 changes: 22 additions & 0 deletions gameoflife-acceptance-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM selenium/standalone-firefox:latest

ENV MAVEN_VERSION 3.3.3
ENV DISPLAY :99

USER root

RUN apt-get update -qqy \
&& apt-get install -y openjdk-8-jdk && \
rm -rf /var/lib/apt/lists/*

RUN wget -O- http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar xzf - -C /opt \
&& mv /opt/apache-maven-$MAVEN_VERSION /opt/maven \
&& ln -s /opt/maven/bin/mvn /usr/bin/mvn

USER seluser

ENV MAVEN_HOME /opt/maven

EXPOSE 9090

CMD ["mvn"]
14 changes: 7 additions & 7 deletions gameoflife-acceptance-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<jetty.stop.port>9999</jetty.stop.port>
<webdriver.base.url>http://localhost:${jetty.port}</webdriver.base.url>
<webdriver.driver>firefox</webdriver.driver>
<thucydides.version>0.9.22</thucydides.version>
<thucydides.version>0.9.268</thucydides.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -71,7 +71,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<skip>true</skip>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -121,28 +121,28 @@
<profile>
<id>development</id>
<properties>
<webdriver.base.url>http://gameoflife-dev.thucydides.cloudbees.net</webdriver.base.url>
<webdriver.driver>htmlunit</webdriver.driver>
<webdriver.base.url>http://gameoflife:${jetty.port}</webdriver.base.url>
<webdriver.driver>firefox</webdriver.driver>
</properties>
</profile>
<profile>
<id>integration</id>
<properties>
<webdriver.base.url>http://gameoflife-integration.thucydides.cloudbees.net/</webdriver.base.url>
<webdriver.base.url>http://gameoflife:${jetty.port}</webdriver.base.url>
<webdriver.driver>firefox</webdriver.driver>
</properties>
</profile>
<profile>
<id>staging</id>
<properties>
<webdriver.base.url>http://gameoflife-staging.thucydides.cloudbees.net</webdriver.base.url>
<webdriver.base.url>http://gameoflife:${jetty.port}</webdriver.base.url>
<webdriver.driver>firefox</webdriver.driver>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<webdriver.base.url>http://gameoflife.thucydides.cloudbees.net/</webdriver.base.url>
<webdriver.base.url>http://gameoflife:${jetty.port}</webdriver.base.url>
<webdriver.driver>firefox</webdriver.driver>
</properties>
</profile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package com.wakaleo.gameoflife.domain;

/**
* Wakaleo Consulting - John Ferguson Smart
* Game of life, demonstration application for Jenkins: The Definitive Guide
*
* Cell.java
* Cell object class, contains information on individual cells (positions) in the grid
*/
public enum Cell {
// Symbols to represent cell status
LIVE_CELL("*"), DEAD_CELL(".");

private String symbol;
Expand All @@ -9,11 +17,14 @@ private Cell(final String initialSymbol) {
this.symbol = initialSymbol;
}

// Override function for easy printing of cell's symbol
// Functions identically to default getter ( getSymbol() )
@Override
public String toString() {
return symbol;
}

// Function used for creating a cell given a string
static Cell fromSymbol(final String symbol) {
Cell cellRepresentedBySymbol = null;
for (Cell cell : Cell.values()) {
Expand All @@ -25,6 +36,7 @@ static Cell fromSymbol(final String symbol) {
return cellRepresentedBySymbol;
}

// Default getter
public String getSymbol() {
return symbol;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,73 @@
import static com.wakaleo.gameoflife.domain.Cell.DEAD_CELL;
import static com.wakaleo.gameoflife.domain.Cell.LIVE_CELL;

/**
* Wakaleo Consulting - John Ferguson Smart
* Game of life, demonstration application for Jenkins: The Definitive Guide
*
* Grid.java
* Grid object class, containing information on a collection of cells
*/
public class Grid {

private static final int DEFAULT_ROW_COUNT = 3;
private static final int DEFAULT_COLUMN_COUNT = 3;

private Cell[][] cells;


// Helper classes with functions to access cell information
private GridReader gridReader = new GridReader();
private GridWriter gridWriter = new GridWriter();

public Grid(final String gridContents) {
this.cells = makeCellArrayFrom(gridContents);
}

// Default constructor, called on "NEW GAME" button click
public Grid() {
this.cells = anArrayOfDeadCells(DEFAULT_ROW_COUNT,
DEFAULT_COLUMN_COUNT);
this.cells = anArrayOfDeadCells(DEFAULT_ROW_COUNT, DEFAULT_COLUMN_COUNT);
}

// Create blank grid of given size, called on "Go" button click
public Grid(final int rows, final int columns) {
this.cells = anArrayOfDeadCells(rows, columns);
}
// Create grid given cell layout, called on "Next Generation" button click
public Grid(final String gridContents) {
this.cells = makeCellArrayFrom(gridContents);
}

// Convert input string of symbols into 2D array of cell objects
private Cell[][] makeCellArrayFrom(final String gridContents) {
return gridReader.loadFrom(gridContents);
}

// Helper function, populates grid with dead cells
private Cell[][] anArrayOfDeadCells(final int rows, final int columns) {
Cell[][] deadCells = new Cell[rows][columns];
Cell[][] deadCells = new Cell[rows][columns]; // First create an empty 2D array of cells
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
deadCells[i][j] = DEAD_CELL;
deadCells[i][j] = DEAD_CELL; // Then set each one's status to DEAD
}
}
return deadCells;
}

private Cell[][] makeCellArrayFrom(final String gridContents) {
return gridReader.loadFrom(gridContents);
}

// Override function for easy printing of entire grids
@Override
public String toString() {
return gridWriter.convertToString(cells);
}

// Calculates the number of neighbours with LIVE status, called when creating the game-of-life's next step
public int getLiveNeighboursAt(final int x, final int y) {
int liveNeighbourCount = 0;
// "neighbouring cells" are positions adjacent horizontally, vertically, and diagonally
for (int xPosition = x - 1; xPosition <= x + 1; xPosition++) {
for (int yPosition = y - 1; yPosition <= y + 1; yPosition++) {
if (!cellIsCentralCell(xPosition, yPosition, x, y)) {
liveNeighbourCount += countLiveNeighboursInCell(xPosition, yPosition);
if (!cellIsCentralCell(xPosition, yPosition, x, y)) { // Cell does not count itself as a neighbour
liveNeighbourCount += countLiveNeighboursInCell(xPosition, yPosition); // Increment counter if LIVE
}
}
}
return liveNeighbourCount;
}

// Helper function, returns 1 if the cell at the given coordinate is LIVE, else 0
private int countLiveNeighboursInCell(final int x, final int y) {
if (cellIsOutsideBorders(x, y)) {
return 0;
Expand All @@ -68,7 +80,7 @@ private int countLiveNeighboursInCell(final int x, final int y) {
return 0;
}
}

// Helper function, validates if given coordinate is within the grid size
private boolean cellIsOutsideBorders(final int x, final int y) {
return (y < 0 || y > getMaxRow()) || (x < 0 || x > getMaxColumn());
}
Expand All @@ -81,6 +93,9 @@ private int getMaxColumn() {
return cells[0].length - 1;
}

// Makes sure cell does not count itself as a neighbour
// In a simple example, creating a new validation function may not be necessary
// However, if validation later becomes complex, a seperate function is good practice
private boolean cellIsCentralCell(final int x, final int y,
final int centerX, final int centerY) {
return (x == centerX) && (y == centerY);
Expand All @@ -102,6 +117,7 @@ public void setCellAt(final int x, final int y, final Cell cell) {
cells[y][x] = cell;
}

// Returns entire grid as 2D array of cell objects
public Cell[][] getContents() {
Cell[][] contentCopy = new Cell[getHeight()][getWidth()];
for (int row = 0; row < getHeight(); row++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,45 @@
import java.util.ArrayList;
import java.util.List;

/**
* Wakaleo Consulting - John Ferguson Smart
* Game of life, demonstration application for Jenkins: The Definitive Guide
*
* GridReader.java
* Class for converting inputted string of state symbols into array of cell objects
*/
public class GridReader {

private static final String NEW_LINE = System.getProperty("line.separator");

// Returns array of cell objects created from inputted string
public Cell[][] loadFrom(final String gridContents) {
List<Cell[]> rows = new ArrayList<Cell[]>();
String[] rowValues = splitIntoRows(gridContents);

String[] rowValues = splitIntoRows(gridContents); // First separate total content into different rows
for (String row : rowValues) {
Cell[] cellsInRow = splitIntoCells(row);
rows.add(cellsInRow);
Cell[] cellsInRow = splitIntoCells(row); // Then separate each row into different cells
rows.add(cellsInRow); // Save the cells of a row into a list
}

// Convert list into 2D array of new cell objects
return (Cell[][]) rows.toArray(new Cell[0][0]);
}

// Helper function, converts series of symbols into array of Cell objects
private Cell[] splitIntoCells(final String row) {
// TODO: ugly code
char[] cellSymbols = row.trim().toCharArray();
char[] cellSymbols = row.trim().toCharArray(); // First convert string into array of state symbols
List<Cell> cellsInRow = new ArrayList<Cell>();
for (char cellSymbol : cellSymbols) {
Cell cell = Cell.fromSymbol(Character.toString(cellSymbol));
for (char cellSymbol : cellSymbols) { // Then for each symbol
Cell cell = Cell.fromSymbol(Character.toString(cellSymbol)); // Create a new cell object
if (cell == null) {
throw new IllegalArgumentException();
}
cellsInRow.add(cell);
cellsInRow.add(cell); // And save it to return
}
return cellsInRow.toArray(new Cell[0]);
}

// Helper function, converts input grid into array of string symbols
private String[] splitIntoRows(final String gridContents) {
return gridContents.split(NEW_LINE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
package com.wakaleo.gameoflife.domain;

/**
* Wakaleo Consulting - John Ferguson Smart
* Game of life, demonstration application for Jenkins: The Definitive Guide
*
* GridWriter.java
* Class for easy printing/showing of the grid contents
*/
public class GridWriter {

private static final String LINE_SEPARATOR = System.getProperty("line.separator");

// Functions returns the status of the cells in the grid as a string, for printing
public String convertToString(final Cell[][] gridContents) {
StringBuffer printedGrid = new StringBuffer();
for (Cell[] row : gridContents) {
for (Cell[] row : gridContents) {
for (Cell cell : row) {
printedGrid.append(cell.toString());
printedGrid.append(cell.toString()); // Save the cell's status for printing
}
// TODO: This simply masks the problem: why empty rows being passed?

// Add seperator to denote the next row
// Note: does not add seperator for empty rows
if (row.length > 0) {
printedGrid.append(LINE_SEPARATOR);
}
Expand Down
Loading