Skip to content

Commit d5c3715

Browse files
committed
Merge branch 'master' into xray-gettingstarted
2 parents e8abe7f + 2783ab4 commit d5c3715

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ Other branches extend the application's functionality and show the use of other
1313
- [`cognito`](https://github.com/awslabs/eb-java-scorekeep/tree/cognito) - Support login and store users in an [Amazon Cognito](http://aws.amazon.com/cognito) user pool. Get AWS SDK credentials and make service calls with a Cognito identity pool.
1414
- [`cognito-basic`](https://github.com/awslabs/eb-java-scorekeep/tree/cognito-basic) - Use Cognito for user ID storage. User pool only, no identity pool.
1515
- [`lambda`](https://github.com/awslabs/eb-java-scorekeep/tree/lambda) - Call an [AWS Lambda](http://aws.amazon.com/lambda) function to generate random names.
16+
- [`lambda-worker`](https://github.com/awslabs/eb-java-scorekeep/tree/lambda-worker) - Run a Lambda function periodically to process game records and store the output in Amazon S3.
1617
- [`sql`](https://github.com/awslabs/eb-java-scorekeep/tree/sql) - Use JDBC to store game histories in an attached PostgreSQL database instance.
1718
- [`xray`](https://github.com/awslabs/eb-java-scorekeep/tree/xray) - Use the [AWS X-Ray SDK for Java](http://docs.aws.amazon.com/xray-sdk-for-java/latest/javadoc/) to instrument incoming requests, functions, SDK clients, SQL queries, HTTP clients, startup code, and AWS Lambda functions.
1819
- [`xray-cognito`](https://github.com/awslabs/eb-java-scorekeep/tree/xray-cognito) - Use AWS credentials obtained with Amazon Cognito to upload trace data to X-Ray from the browser.
1920
- [`xray-gettingstarted`](https://github.com/awslabs/eb-java-scorekeep/tree/xray-gettingstarted) ([tutorial](https://docs.aws.amazon.com/xray/latest/devguide/xray-gettingstarted.html)) - Use the AWS X-Ray SDK for Java to instrument incoming requests and SDK clients (no additional configuration required).
21+
- [`xray-worker`](https://github.com/awslabs/eb-java-scorekeep/tree/xray-worker) - Instrumented Python Lambda worker function from the `lambda-worker` branch.
2022

2123
Use the procedures in the following sections to run the project on Elastic Beanstalk and configure it for local testing and development.
2224

build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ buildscript {
55
dependencies {
66
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
77
classpath("io.spring.gradle:dependency-management-plugin:0.5.4.RELEASE")
8+
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
89
}
910
}
1011

@@ -13,6 +14,7 @@ apply plugin: 'eclipse'
1314
apply plugin: 'idea'
1415
apply plugin: 'spring-boot'
1516
apply plugin: 'io.spring.dependency-management'
17+
apply plugin: 'org.junit.platform.gradle.plugin'
1618

1719
jar {
1820
baseName = 'scorekeep-api'
@@ -34,8 +36,9 @@ dependencies {
3436
compile("com.amazonaws:aws-xray-recorder-sdk-core")
3537
compile("com.amazonaws:aws-xray-recorder-sdk-aws-sdk")
3638
compile("com.amazonaws:aws-xray-recorder-sdk-aws-sdk-instrumentor")
37-
testCompile("junit:junit:4.11")
3839
compile("com.fasterxml.jackson.core:jackson-databind:2.8.4")
40+
testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0")
41+
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.0")
3942
}
4043

4144
dependencyManagement {

src/main/java/scorekeep/Game.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class Game {
2121
private String rules;
2222
private Date startTime;
2323
private Date endTime;
24-
private ArrayList<String> states;
25-
private ArrayList<String> moves;
24+
private List<String> states;
25+
private List<String> moves;
2626

2727
public Game() {
2828
}
@@ -95,10 +95,10 @@ public void setEndTime(Date endTime) {
9595
}
9696

9797
@DynamoDBAttribute(attributeName="states")
98-
public ArrayList<String> getStates() {
98+
public List<String> getStates() {
9999
return states;
100100
}
101-
public void setStates(ArrayList<String> states) {
101+
public void setStates(List<String> states) {
102102
this.states = states;
103103
}
104104
public void setState(String state) {
@@ -109,10 +109,10 @@ public void setState(String state) {
109109
}
110110

111111
@DynamoDBAttribute(attributeName="moves")
112-
public ArrayList<String> getMoves() {
112+
public List<String> getMoves() {
113113
return moves;
114114
}
115-
public void setMoves(ArrayList<String> moves) {
115+
public void setMoves(List<String> moves) {
116116
this.moves = moves;
117117
}
118118
public void setMove(String move) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package scorekeep;
2+
import static org.junit.jupiter.api.Assertions.assertEquals;
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import java.util.ArrayList;
6+
import java.util.Arrays;
7+
import java.util.List;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
10+
11+
import org.junit.jupiter.api.Test;
12+
13+
class TicTacToeTest {
14+
private static final Logger logger = LoggerFactory.getLogger(TicTacToe.class);
15+
16+
@Test
17+
void gameplayTest() {
18+
Rules rules = TicTacToe.getRules();
19+
String state = rules.getInitialState();
20+
List<String> moves = new ArrayList<String>(Arrays.asList("X1", "O3", "X4", "O6", "X7"));
21+
for (String move : moves) {
22+
state = TicTacToe.move(state, move);
23+
}
24+
assertTrue(TicTacToe.checkWin(TicTacToe.toInt(state.toCharArray(), 'X')));
25+
}
26+
@Test
27+
void checkWinTest() {
28+
String state = "OX O XO X";
29+
assertTrue(TicTacToe.checkWin(TicTacToe.toInt(state.toCharArray(), 'X')));
30+
}
31+
32+
}

0 commit comments

Comments
 (0)