Skip to content

Commit 1099235

Browse files
committed
adding some hints and solutions and an HTTP test class for the simulator examples
1 parent 4a1bc15 commit 1099235

File tree

10 files changed

+373
-5
lines changed

10 files changed

+373
-5
lines changed

challenger/src/main/java/uk/co/compendiumdev/challenge/challenges/ChallengeDefinitions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public ChallengeDefinitions(ChallengerConfig config){
8282

8383
// CREATE with POST
8484
ChallengeSection postCreateChallenges = new ChallengeSection("Creation Challenges with POST",
85-
"A POST request can be used to create and update data, these challenges are to 'create' data. As a Hint, if you are not sure what the message body should be, try copying in the response from the associated GET request, and amending it.");
85+
"A POST request can be used to create and update data, these challenges are to 'create' data.");
8686
sections.add(postCreateChallenges);
8787

8888
storeChallengeAs(CHALLENGE.POST_TODOS, PostChallenges.postTodos201(challengeOrder++), postCreateChallenges);
@@ -97,7 +97,7 @@ public ChallengeDefinitions(ChallengerConfig config){
9797

9898
// CREATE with PUT
9999
ChallengeSection putCreateChallenges = new ChallengeSection("Creation Challenges with PUT",
100-
"A PUT request can often used to create and update data. The todo application we are using has automatically generated ids, so you cannot use PUT to create. As a Hint, if you are not sure what the message body should be, try copying in the response from the associated GET request, and amending it.");
100+
"A PUT request can often used to create and update data. The todo application we are using has automatically generated ids, so you cannot use PUT to create.");
101101
sections.add(putCreateChallenges);
102102

103103
storeChallengeAs(CHALLENGE.PUT_TODOS_400, PutChallenges.putTodosId400(challengeOrder++), putCreateChallenges);

challenger/src/main/java/uk/co/compendiumdev/challenge/challenges/definitions/ChallengerChallenges.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static ChallengeDefinitionData createChallenger201(int challengeOrder) {
1010
"POST /challenger (201)",
1111
"Issue a POST request on the `/challenger` end point, with no body, to create a new challenger session. Use the generated X-CHALLENGER header in future requests to track challenge completion."
1212
);
13-
aChallenge.addHint("In multi-user mode, you need to create an X-CHALLENGER Session first", "/gui/multiuser");
13+
aChallenge.addHint("In multi-user mode, you need to create an X-CHALLENGER Session in order to complete any challenges or make PUT, POST, DELETE requests", "/gui/multiuser");
1414
aChallenge.addSolutionLink("Send request using POST to /challenger endpoint. The response has an X-CHALLENGER header, add this header X-CHALLENGER and the GUID value to all future requests.","","");
1515
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/create-session/post-challenger-201");
1616
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "tNGuZMQgHxw");

challenger/src/main/java/uk/co/compendiumdev/challenge/challenges/definitions/GetChallenges.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public static ChallengeDefinitionData getChallenges200(int challengeOrder) {
1010
"GET /challenges (200)",
1111
"Issue a GET request on the `/challenges` end point");
1212

13+
aChallenge.addHint("Remember to add the X-CHALLENGER header so you see the progress of the challenges for your session.", "");
14+
aChallenge.addHint("If you issue a GET request without an X-CHALLENGER header you will see the default challenge values.", "");
15+
aChallenge.addHint("By default the response body will be JSON format.", "");
16+
1317
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/first-challenge/get-challenges-200");
1418
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "DrAjk2NaPRo");
1519

@@ -23,6 +27,10 @@ public static ChallengeDefinitionData getTodos200(int challengeOrder) {
2327
"GET /todos (200)",
2428
"Issue a GET request on the `/todos` end point");
2529

30+
aChallenge.addHint("Remember to add the X-CHALLENGER header so you see the data for your session.", "");
31+
aChallenge.addHint("If you issue a GET request without an X-CHALLENGER header you will see the default todo values.", "");
32+
aChallenge.addHint("By default the response body will be JSON format.", "");
33+
2634
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/get/get-todos-200");
2735
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "OpisB0UZq0c");
2836

@@ -35,6 +43,7 @@ public static ChallengeDefinitionData getTodos404(int challengeOrder) {
3543
"GET /todo (404) not plural",
3644
"Issue a GET request on the `/todo` end point should 404 because nouns should be plural");
3745

46+
3847
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/get/get-todo-404");
3948
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "gAJzqgcN9dc");
4049

@@ -48,6 +57,7 @@ public static ChallengeDefinitionData getTodo200(int challengeOrder) {
4857
"Issue a GET request on the `/todos/{id}` end point to return a specific todo");
4958

5059
aChallenge.addHint("Make sure you don't use {id} in the url, replace that with the id of a todo e.g. /todos/1");
60+
5161
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/get/get-todos-id-200");
5262
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "JDbbSY3U_rY");
5363

@@ -63,6 +73,7 @@ public static ChallengeDefinitionData getTodo404(int challengeOrder) {
6373
aChallenge.addHint("Make sure you don't use {id} in the url, replace that with the id of a todo e.g. /todos/1");
6474
aChallenge.addHint("Make sure the id is an integer e.g. /todos/1");
6575
aChallenge.addHint("Make sure you are using the /todos end point e.g. /todos/1");
76+
6677
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/get/get-todos-id-404");
6778
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "1S5kpd8-xfM");
6879

@@ -74,10 +85,12 @@ public static ChallengeDefinitionData getTodosFiltered200(int challengeOrder) {
7485
ChallengeRenderer.renderChallengeNumber(challengeOrder),
7586
"GET /todos (200) ?filter",
7687
"Issue a GET request on the `/todos` end point with a query filter to get only todos which are 'done'. There must exist both 'done' and 'not done' todos, to pass this challenge.");
88+
7789
aChallenge.addHint("A query filter is a URL parameter using the field name and a value");
7890
aChallenge.addHint("A URL parameter is added to the end of a url with a ? e.g. /todos?id=1");
7991
aChallenge.addHint("To filter on 'done' we use the 'doneStatus' field ? e.g. ?doneStatus=true");
8092
aChallenge.addHint("Make sure there are todos which are done, and not yet done");
93+
8194
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/get/get-todos-200-filter");
8295
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "G-sLuhyPMuw");
8396
return aChallenge;

challenger/src/main/java/uk/co/compendiumdev/challenge/challenges/definitions/PostChallenges.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package uk.co.compendiumdev.challenge.challenges.definitions;
22

3-
import uk.co.compendiumdev.challenge.CHALLENGE;
43
import uk.co.compendiumdev.challenge.challenges.ChallengeDefinitionData;
54

65
public class PostChallenges {
@@ -16,6 +15,11 @@ public static ChallengeDefinitionData postTodos201(int challengeOrder) {
1615
"POST /todos (201)",
1716
"Issue a POST request to successfully create a todo");
1817

18+
aChallenge.addHint("Add a JSON payload in the request", "");
19+
aChallenge.addHint("If you don't know the format of the payload, use the response from a GET /todos/{id} request and amend it", "");
20+
aChallenge.addHint("You must add an X-CHALLENGER header for a valid session", "");
21+
22+
1923
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/post-create/post-todos-201");
2024
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "T0LFHwavsNA");
2125
return aChallenge;
@@ -40,6 +44,8 @@ public static ChallengeDefinitionData postTodosBadDoneStatus400(int challengeOrd
4044
"POST /todos (400) doneStatus",
4145
"Issue a POST request to create a todo but fail validation on the `doneStatus` field");
4246

47+
aChallenge.addHint("doneStatus should be boolean, an invalid status would be a String or a number e.g. \"invalid\"");
48+
4349
aChallenge.addSolutionLink("Read Solution", "HREF", "/apichallenges/solutions/post-create/post-todos-400");
4450
aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "tlye5bQ72g0");
4551
return aChallenge;

challenger/src/main/java/uk/co/compendiumdev/challenge/challenges/definitions/PutChallenges.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public static ChallengeDefinitionData putTodosId400(int challengeOrder) {
1010
"PUT /todos/{id} (400)",
1111
"Issue a PUT request to unsuccessfully create a todo");
1212

13+
aChallenge.addHint("Add a JSON payload in the request", "");
14+
aChallenge.addHint("If you don't know the format of the payload, use the response from a GET /todos/{id} request and amend it", "");
15+
aChallenge.addHint("Do not include an 'id' in the payload", "");
16+
aChallenge.addHint("You must add an X-CHALLENGER header for a valid session", "");
17+
1318
// todo: create solution for PUT todos 400 challenge
1419
//aChallenge.addSolutionLink("Read Solution", "HREF", "https://www.eviltester.com/apichallenges/howto/post-todos-201");
1520
//aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "T0LFHwavsNA");
@@ -26,6 +31,10 @@ public static ChallengeDefinitionData putTodosIdFull200(int challengeOrder) {
2631
"PUT /todos/{id} full (200)",
2732
"Issue a PUT request to update an existing todo with a complete payload i.e. title, description and donestatus.");
2833

34+
aChallenge.addHint("Add a JSON payload in the request", "");
35+
aChallenge.addHint("If you don't know the format of the payload, use the response from a GET /todos/{id} request and amend it", "");
36+
aChallenge.addHint("Do not include an 'id' in the payload", "");
37+
2938
// todo: create solution for PUT todos full 200 challenge
3039
//aChallenge.addSolutionLink("Read Solution", "HREF", "https://www.eviltester.com/apichallenges/howto/post-todos-201");
3140
//aChallenge.addSolutionLink("Watch Insomnia Solution", "YOUTUBE", "T0LFHwavsNA");

challenger/src/main/resources/content/practice-modes/simulation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ To find out what Verbs, or Methods, we are allowed to use, issue an `OPTIONS` re
250250
OPTIONS {{<ORIGIN_URL>}}/sim/entities
251251
```
252252

253-
By looking at the `Accept` header in the response we can see that we are allowed to `GET, POST, PUT, HEAD, OPTIONS`
253+
By looking at the `Allow` header in the response we can see that we are allowed to `GET, POST, PUT, HEAD, OPTIONS`
254254

255255
If we tried to `DELETE` or `PATCH` then we should receive an appropriate status code of `405`
256256

challengerAuto/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
<version>${junit.jupiter.version}</version>
3737
<scope>test</scope>
3838
</dependency>
39+
<dependency>
40+
<groupId>org.junit.jupiter</groupId>
41+
<artifactId>junit-jupiter-params</artifactId>
42+
<version>${junit.jupiter.version}</version>
43+
<scope>test</scope>
44+
</dependency>
3945

4046
<dependency>
4147
<groupId>io.rest-assured</groupId>

0 commit comments

Comments
 (0)