-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add missing challenge tests, fix typo in save state
- Loading branch information
1 parent
fe002c9
commit 7a778a2
Showing
7 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../restassured/_13_restore_session_challenges/C034GetChallengerSessionForRestoringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package uk.co.compendiumdev.challenger.restassured._13_restore_session_challenges; | ||
|
||
import com.google.gson.Gson; | ||
import io.restassured.RestAssured; | ||
import io.restassured.http.ContentType; | ||
import io.restassured.response.Response; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import uk.co.compendiumdev.challenger.payloads.Challenger; | ||
import uk.co.compendiumdev.challenger.restassured.api.ChallengesStatus; | ||
import uk.co.compendiumdev.challenger.restassured.api.RestAssuredBaseTest; | ||
|
||
public class C034GetChallengerSessionForRestoringTest extends RestAssuredBaseTest { | ||
|
||
@Test | ||
public void canGetChallengerSession(){ | ||
|
||
Assertions.assertNotNull(xChallenger); | ||
Assertions.assertTrue(xChallenger.length()>5); | ||
|
||
Response cResponse = RestAssured. | ||
given(). | ||
header("X-CHALLENGER", xChallenger). | ||
accept("application/json"). | ||
get(apiPath("/challenger/" + xChallenger)). | ||
then(). | ||
statusCode(200). | ||
contentType(ContentType.JSON).and().extract().response(); | ||
|
||
Challenger challengerResponse = new Gson().fromJson(cResponse.body().asString(), Challenger.class); | ||
|
||
Assertions.assertTrue(challengerResponse.challengeStatus.GET_RESTORABLE_CHALLENGER_PROGRESS_STATUS); | ||
|
||
ChallengesStatus statuses = new ChallengesStatus(); | ||
statuses.get(); | ||
Assertions.assertTrue(statuses.getChallengeNamed("GET /challenger/guid (existing X-CHALLENGER)").status, | ||
"challenge not passed"); | ||
|
||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...nger/restassured/_13_restore_session_challenges/C037GetTodosDatabaseForRestoringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package uk.co.compendiumdev.challenger.restassured._13_restore_session_challenges; | ||
|
||
import com.google.gson.Gson; | ||
import io.restassured.RestAssured; | ||
import io.restassured.http.ContentType; | ||
import io.restassured.response.Response; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import uk.co.compendiumdev.challenger.payloads.Challenger; | ||
import uk.co.compendiumdev.challenger.payloads.Todos; | ||
import uk.co.compendiumdev.challenger.restassured.api.ChallengesStatus; | ||
import uk.co.compendiumdev.challenger.restassured.api.RestAssuredBaseTest; | ||
|
||
public class C037GetTodosDatabaseForRestoringTest extends RestAssuredBaseTest { | ||
|
||
@Test | ||
public void canGetTodosForChallengerSession(){ | ||
|
||
Assertions.assertNotNull(xChallenger); | ||
Assertions.assertTrue(xChallenger.length()>5); | ||
|
||
Response todoResponse = RestAssured. | ||
given(). | ||
header("X-CHALLENGER", xChallenger). | ||
accept("application/json"). | ||
get(apiPath("/challenger/database/" + xChallenger)). | ||
then(). | ||
statusCode(200). | ||
contentType(ContentType.JSON).and().extract().response(); | ||
|
||
Todos todosResponse = new Gson().fromJson(todoResponse.body().asString(), Todos.class); | ||
Assertions.assertFalse(todosResponse.todos.isEmpty()); | ||
|
||
|
||
Response cResponse = RestAssured. | ||
given(). | ||
header("X-CHALLENGER", xChallenger). | ||
accept("application/json"). | ||
get(apiPath("/challenger/" + xChallenger)). | ||
then(). | ||
statusCode(200). | ||
contentType(ContentType.JSON).and().extract().response(); | ||
|
||
Challenger challengerResponse = new Gson().fromJson(cResponse.body().asString(), Challenger.class); | ||
Assertions.assertTrue(challengerResponse.challengeStatus.GET_RESTORABLE_TODOS); | ||
|
||
ChallengesStatus statuses = new ChallengesStatus(); | ||
statuses.get(); | ||
Assertions.assertTrue(statuses.getChallengeNamed("GET /challenger/database/guid (200)").status, | ||
"challenge not passed"); | ||
|
||
} | ||
} |