diff --git a/.github/stale.yml b/.github/stale.yml
new file mode 100644
index 0000000000..6268bf8916
--- /dev/null
+++ b/.github/stale.yml
@@ -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.
diff --git a/.github/walmart-probot-buddy.yml b/.github/walmart-probot-buddy.yml
new file mode 100644
index 0000000000..6e9d2b3852
--- /dev/null
+++ b/.github/walmart-probot-buddy.yml
@@ -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\/"]
+ }
\ No newline at end of file
diff --git a/README.markdown b/README.markdown
index 755adee584..470eaf98e8 100644
--- a/README.markdown
+++ b/README.markdown
@@ -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
@@ -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
\ No newline at end of file
diff --git a/gameoflife-acceptance-tests/Dockerfile b/gameoflife-acceptance-tests/Dockerfile
new file mode 100644
index 0000000000..8fdd2d25a5
--- /dev/null
+++ b/gameoflife-acceptance-tests/Dockerfile
@@ -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"]
diff --git a/gameoflife-acceptance-tests/pom.xml b/gameoflife-acceptance-tests/pom.xml
index 2a33e57db3..532ceed248 100644
--- a/gameoflife-acceptance-tests/pom.xml
+++ b/gameoflife-acceptance-tests/pom.xml
@@ -13,7 +13,7 @@
9999http://localhost:${jetty.port}firefox
- 0.9.22
+ 0.9.268
@@ -71,7 +71,7 @@
maven-surefire-plugin2.9
- true
+ false
@@ -121,28 +121,28 @@
development
- http://gameoflife-dev.thucydides.cloudbees.net
- htmlunit
+ http://gameoflife:${jetty.port}
+ firefoxintegration
- http://gameoflife-integration.thucydides.cloudbees.net/
+ http://gameoflife:${jetty.port}firefoxstaging
- http://gameoflife-staging.thucydides.cloudbees.net
+ http://gameoflife:${jetty.port}firefoxproduction
- http://gameoflife.thucydides.cloudbees.net/
+ http://gameoflife:${jetty.port}firefox
diff --git a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Cell.java b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Cell.java
index 47e1ca870c..ae8cd3cb3f 100644
--- a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Cell.java
+++ b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Cell.java
@@ -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;
@@ -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()) {
@@ -25,6 +36,7 @@ static Cell fromSymbol(final String symbol) {
return cellRepresentedBySymbol;
}
+ // Default getter
public String getSymbol() {
return symbol;
}
diff --git a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Grid.java b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Grid.java
index 88f7a1f374..e0078ca087 100644
--- a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Grid.java
+++ b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Grid.java
@@ -3,6 +3,13 @@
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;
@@ -10,54 +17,59 @@ public class Grid {
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;
@@ -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());
}
@@ -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);
@@ -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++) {
diff --git a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridReader.java b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridReader.java
index 6564bd80f6..240ef5dd07 100644
--- a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridReader.java
+++ b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridReader.java
@@ -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 rows = new ArrayList();
- 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 cellsInRow = new ArrayList();
- 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);
}
diff --git a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridWriter.java b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridWriter.java
index 3691d0a734..2b7505d56f 100644
--- a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridWriter.java
+++ b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/GridWriter.java
@@ -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);
}
diff --git a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Universe.java b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Universe.java
index 79affc236a..3928fff39d 100644
--- a/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Universe.java
+++ b/gameoflife-core/src/main/java/com/wakaleo/gameoflife/domain/Universe.java
@@ -3,7 +3,11 @@
import static com.wakaleo.gameoflife.domain.Cell.LIVE_CELL;
import static com.wakaleo.gameoflife.domain.Cell.DEAD_CELL;
-/**
+ /**
+ * Wakaleo Consulting - John Ferguson Smart
+ * Game of life, demonstration application for Jenkins: The Definitive Guide
+ *
+ * Universe.java
* A universe is a succession of grids over time.
* Each new grid is generated from the previous one using the rules of the Game Of Life.
*/
@@ -13,49 +17,52 @@ public class Universe {
private Grid currentGridContent;
+ // Default constructor, called on "NEW GAME" button click
public Universe() {
currentGridContent = new Grid();
}
-
+ // Create blank grid of given size, called on "Go" button click
public Universe(final int rows, final int columns) {
currentGridContent = new Grid(rows, columns);
}
-
+ // Create grid given cell layout, called on "Next Generation" button click
public Universe(final String initialGridContents) {
currentGridContent = new Grid(initialGridContents);
}
+ // Returns the input string, functions as the Universe class' print
public static String seededWith(final String gridContents) {
return gridContents;
}
+ // Calculates the game-of-life's next iteration, called on "Next Generation" button click
public void spawnsANewGeneration() {
createNextGeneration();
}
-
public void createNextGeneration() {
-
StringBuffer nextGenerationContent = new StringBuffer();
-
int maxRow = currentGridContent.getWidth();
int maxColumn = currentGridContent.getHeight();
- // TODO: simplify this code
- for (int y = 0; y < maxRow; y++) {
- for (int x = 0; x < maxColumn; x++) {
+
+ // Iterates over entire grid
+ for (int y = 0; y < maxRow; y++) { // From top to bottom
+ for (int x = 0; x < maxColumn; x++) { // From left to right
Cell currentCell = currentGridContent.getCellAt(x, y);
- int neighbourCount = currentGridContent.getLiveNeighboursAt(x, y);
+ int neighbourCount = currentGridContent.getLiveNeighboursAt(x, y); // getLiveNeighboursAt() defined in Grid.java
Cell nextCell = null;
- if (currentCell == Cell.LIVE_CELL) {
+
+ // Based on the rules of game-of-life, calculate next state
+ if (currentCell == Cell.LIVE_CELL) { // If cell is currently LIVE
if ((neighbourCount == 2) || (neighbourCount == 3)) {
- nextCell = LIVE_CELL;
+ nextCell = LIVE_CELL; // Stay LIVE if 2 or 3 neighbours are LIVE
} else {
- nextCell = DEAD_CELL;
+ nextCell = DEAD_CELL; // Else, become DEAD due to underpopulation or overcrowding
}
- } else {
+ } else { // If cell is currently DEAD
if (neighbourCount == 3) {
- nextCell = LIVE_CELL;
+ nextCell = LIVE_CELL; // Become LIVE if 3 neighbours are LIVE
} else {
- nextCell = DEAD_CELL;
+ nextCell = DEAD_CELL; // Else, stay DEAD
}
}
nextGenerationContent.append(nextCell);
@@ -63,26 +70,31 @@ public void createNextGeneration() {
nextGenerationContent.append(NEW_LINE);
}
nextGenerationContent.append(NEW_LINE);
+
+ // Sets the finalized grid of the game-of-life's next step
currentGridContent = new Grid(nextGenerationContent.toString());
}
+ // Return the status of every cell as a string
public String getGrid() {
return currentGridContent.toString();
}
-
+ // Return the cell objects in the grid as a 2D array
public Cell[][] getCells() {
return currentGridContent.getContents();
}
+ // Set cell at given coordinate to LIVE
public void setLiveCellAt(final int row, final int column) {
this.currentGridContent.setCellAt(column, row, LIVE_CELL);
}
+ // Set cell at given coordinate to DEAD
+ public void setDeadCellAt(final int row, final int column) {
+ this.currentGridContent.setCellAt(column, row, DEAD_CELL);
+ }
+ // Return the cell object at the given coordinate
public Cell getCellAt(final int row, final int column) {
return currentGridContent.getCellAt(column, row);
}
-
- public void setDeadCellAt(final int row, final int column) {
- this.currentGridContent.setCellAt(column, row, DEAD_CELL);
- }
}
diff --git a/gameoflife-web/Dockerfile b/gameoflife-web/Dockerfile
new file mode 100644
index 0000000000..d7d242da99
--- /dev/null
+++ b/gameoflife-web/Dockerfile
@@ -0,0 +1,8 @@
+FROM tomcat:8-jre8
+
+RUN rm -rf /usr/local/tomcat/webapps/*
+
+COPY target/gameoflife.war /usr/local/tomcat/webapps/ROOT.war
+
+EXPOSE 8080
+CMD ["catalina.sh", "run"]
diff --git a/gameoflife-web/pom.xml b/gameoflife-web/pom.xml
index ebba304fc7..fada8b2196 100644
--- a/gameoflife-web/pom.xml
+++ b/gameoflife-web/pom.xml
@@ -25,22 +25,20 @@
-
- org.mortbay.jetty
- jetty-maven-plugin
- 7.1.0.v20100505
-
- 10
-
-
- ${jetty.port}
- 60000
-
-
- foo
- ${jetty.stop.port}
-
-
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ 9.3.0.v20150612
+
+ 10
+
+ ${jetty.port}
+ 60000
+
+ foo
+ ${jetty.stop.port}
+
+ maven-war-plugin2.1.1
@@ -58,12 +56,12 @@
- net.thucydides.maven.plugins
- maven-thucydides-plugin
+ net.serenity-bdd.maven.plugins
+ serenity-maven-plugin${thucydides.version}
- thucydides-reports
+ serenity-reportspost-integration-testaggregate
diff --git a/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/GameController.java b/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/GameController.java
index 219b6020ae..12891b6fd0 100644
--- a/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/GameController.java
+++ b/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/GameController.java
@@ -11,46 +11,56 @@
import com.wakaleo.gameoflife.domain.Universe;
+ /**
+ * Wakaleo Consulting - John Ferguson Smart
+ * Game of life, demonstration application for Jenkins: The Definitive Guide
+ *
+ * GameController.java
+ * Controller to navigate the buttons on the game pages
+ */
@Controller
@RequestMapping("/game")
public class GameController {
-
+ // For generating random thread sleep times
private Random randomGenerator = new Random();
+ // Clicking the "New Game" button on the main page loads the cell seletion page
@RequestMapping("/new")
public ModelAndView newGame() {
ModelAndView mav = new ModelAndView("game/edit");
Universe universe = new Universe();
mav.addObject("universe", universe);
- thinkABit(250);
+ thinkABit(250); // Pause for random time
return mav;
}
+ // Clicking the "Go" button on the cell selection page loads the initial step of the game
@RequestMapping("/start")
public ModelAndView firstGeneration(@RequestParam("rows") final int rows,
@RequestParam("columns") final int columns,
final HttpServletRequest request) {
Universe universe = universeInstanciatedFromClickedCells(rows, columns, request);
- thinkABit(200);
+ thinkABit(200); // Pause for random time
return showGridScreen(universe);
}
+ // Clicking the "Next Generation" button loads the next step of the game
@RequestMapping("/next")
public ModelAndView nextGeneration(@RequestParam("rows") final int rows,
@RequestParam("columns") final int columns,
final HttpServletRequest request) {
- Universe universe = universeInstanciatedFromClickedCells(rows, columns,
- request);
+ Universe universe = universeInstanciatedFromClickedCells(rows, columns, request);
universe.createNextGeneration();
- thinkABit(250);
+ thinkABit(250); // Pause for random time
return showGridScreen(universe);
}
+ // Pause for a random time between 0 and given input divided by 4
private void thinkABit(final int max) {
int thinkingTime = getRandomGenerator().nextInt(max / 4);
try {
@@ -60,23 +70,24 @@ private void thinkABit(final int max) {
}
}
+ // Creates new grid for the next step, initialize with all dead cells
private Universe universeInstanciatedByDimensions(final int rows, final int columns) {
Universe universe = new Universe(rows, columns);
for (int row = 0; row < rows; row++) {
for (int column = 0; column < columns; column++) {
- universe.setDeadCellAt(row, column);
+ universe.setDeadCellAt(row, column); // Dead state at every cell position
}
}
return universe;
}
-
+ // Populate the created grid with live cells where selected
private Universe universeInstanciatedFromClickedCells(final int rows,
final int columns,
final HttpServletRequest request) {
Universe universe = universeInstanciatedByDimensions(rows, columns);
for (int row = 0; row < rows; row++) {
for (int column = 0; column < columns; column++) {
- if (cellWasClickedAt(row, column, request)) {
+ if (cellWasClickedAt(row, column, request)) { // Find if checkbox was selected on the previous page
universe.setLiveCellAt(row, column);
}
}
@@ -84,6 +95,7 @@ private Universe universeInstanciatedFromClickedCells(final int rows,
return universe;
}
+ // Display the game-of-life grid page
private ModelAndView showGridScreen(final Universe universe) {
ModelAndView mav = new ModelAndView("game/show");
mav.addObject("universe", universe);
@@ -92,6 +104,7 @@ private ModelAndView showGridScreen(final Universe universe) {
return mav;
}
+ // Determines if the user selected the checkbox at the given coordinate
private boolean cellWasClickedAt(final int row,
final int column,
final HttpServletRequest request) {
@@ -99,6 +112,8 @@ private boolean cellWasClickedAt(final int row,
return (request.getParameter(cellName) != null);
}
+ // Getter for this class' random number generator
+ // Good practice to avoid directly accessing attributes, use getters and setters instead
private Random getRandomGenerator() {
return randomGenerator;
}
diff --git a/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/HomePageController.java b/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/HomePageController.java
index 91535983c5..547994f43b 100644
--- a/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/HomePageController.java
+++ b/gameoflife-web/src/main/java/com/wakaleo/gameoflife/webtests/controllers/HomePageController.java
@@ -4,19 +4,21 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
-/**
- * This class rocks.
+ /**
+ * Wakaleo Consulting - John Ferguson Smart
+ * Game of life, demonstration application for Jenkins: The Definitive Guide
*
- * @author johnsmart
+ * HomePageController.java
+ * Controller to navigate to the main page
*/
@Controller
public class HomePageController {
- // FIXME: do something nicer for the home page
@RequestMapping("/")
public ModelAndView index() {
return new ModelAndView("home");
}
+ // Clicking the "home" text loads the main page
@RequestMapping("/home")
public ModelAndView home() {
return new ModelAndView("home");
diff --git a/pom.xml b/pom.xml
index 445be8f3d7..0eea2ca34b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,12 +10,13 @@
SNAPSHOTUTF-8
- 1.5
- 2.5.1
+ 1.4
+ 2.6
- 1.6
+ 1.8
+ 1.8wakaleo
- 0.9.22
+ 1.8.4gameoflifewakaleo
@@ -29,15 +30,15 @@
maven-compiler-plugin
- 2.2
+ 3.1
-
- 1.6
+
+ 1.7maven-surefire-plugin
- 2.10
+ 2.11true
@@ -78,7 +79,7 @@
org.jacocojacoco-maven-plugin
- 0.5.10.201208310627
+ 0.7.2.201409121644jacoco-initialize
@@ -99,7 +100,7 @@
maven-release-plugin
- 2.2
+ 2.5clean install
@@ -107,7 +108,7 @@
maven-deploy-plugin
- 2.7
+ 2.8.2
@@ -158,7 +159,7 @@
- html
+ html l
${basedir}/target/easyb/easyb-report.html
@@ -187,14 +188,14 @@
junit
- junit-dep
- 4.10
+ junit
+ 4.12testorg.hamcresthamcrest-all
- 1.1
+ 1.3test
@@ -210,18 +211,6 @@
gameoflife-coregameoflife-web
-
-
- wakaleo-releases
- wakaleo-releases
- http://wakaleo.artifactoryonline.com/wakaleo/libs-releases-local
-
-
- wakaleo-snapshots
- wakaleo-snapshots
- http://wakaleo.artifactoryonline.com/wakaleo/libs-snapshots-local
-
- development
@@ -254,7 +243,7 @@
org.apache.maven.pluginsmaven-pmd-plugin
- 2.5
+ 3.21.6true
@@ -309,28 +298,22 @@
org.apache.maven.pluginsmaven-site-plugin
- 3.0
+ 3.3maven-project-info-reports-plugin
- 2.2
+ 2.7
- org.codehaus.mojo
- cobertura-maven-plugin
- ${cobertura.version}
-
-
- html
- xml
-
-
+ org.jacoco
+ jacoco-maven-plugin
+ 0.7.2.201409121644org.apache.maven.pluginsmaven-checkstyle-plugin
- 2.9.1
+ 3.0.1
@@ -338,7 +321,7 @@
org.apache.maven.pluginsmaven-pmd-plugin
- 2.5
+ 3.21.6true
@@ -354,7 +337,7 @@
org.codehaus.mojofindbugs-maven-plugin
- 2.3.2
+ 2.4.0Maxtrue
@@ -362,7 +345,7 @@
maven-javadoc-plugin
- 2.7
+ 2.9.1
@@ -383,7 +366,7 @@
org.apache.maven.pluginsmaven-jxr-plugin
- 2.1
+ 2.4
@@ -477,7 +460,7 @@
org.codehaus.mojofindbugs-maven-plugin
- 2.3
+ 2.4.0Maxtrue