-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matias Schilling
committed
Jun 19, 2024
1 parent
4477c2a
commit 4c26e53
Showing
66 changed files
with
2,689 additions
and
2,290 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ out/ | |
hs_err_pid* | ||
|
||
# Gradle | ||
bin/ | ||
.gradle | ||
build/ | ||
gradle-app.setting | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
interface Version { | ||
public static final String SPRING_BOOT = '2.7.18' | ||
public static final String LOMBOK = '1.18.30' | ||
public static final String JUNIT = '5.10.2' | ||
public static final String REST_ASSURED = '5.4.0' | ||
public static final String SPOTLESS = '7.0.0.BETA1' | ||
public static final String SPRING_BOOT = '2.7.18' | ||
} |
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 |
---|---|---|
@@ -1,2 +1,14 @@ | ||
dependencies { | ||
testImplementation 'commons-logging:commons-logging:1.3.2' | ||
|
||
testImplementation "org.junit.jupiter:junit-jupiter-api:${Version.JUNIT}" | ||
testImplementation "org.junit.jupiter:junit-jupiter:${Version.JUNIT}" | ||
testImplementation("io.rest-assured:json-path:${Version.REST_ASSURED}") { | ||
exclude group: "org.apache.groovy", module: "groovy" | ||
exclude group: "org.apache.groovy", module: "groovy-xml" | ||
} | ||
testImplementation("io.rest-assured:rest-assured:${Version.REST_ASSURED}") { | ||
exclude group: "org.apache.groovy", module: "groovy" | ||
exclude group: "org.apache.groovy", module: "groovy-xml" | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
...knorris-integration-test/src/test/java/io/chucknorris/integration_test/joke/JokeTest.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,61 @@ | ||
package io.chucknorris.integration_test.joke; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import io.restassured.RestAssured; | ||
import java.util.List; | ||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class JokeTest { | ||
|
||
@BeforeAll | ||
public static void beforeAll() { | ||
RestAssured.baseURI = "http://subject"; | ||
RestAssured.port = 8080; | ||
} | ||
|
||
@DisplayName("Should return joke") | ||
@Test | ||
void shouldReturnJoke() { | ||
var specification = given() | ||
.log().all() | ||
.accept("application/json"); | ||
|
||
var response = specification.when().get("/jokes/random"); | ||
|
||
response.then() | ||
.log().all() | ||
.statusCode(200) | ||
.assertThat() | ||
.header("Content-Type", Matchers.equalTo("application/json")) | ||
.body("categories", Matchers.isA(List.class)) | ||
.body("created_at", Matchers.isA(String.class)) | ||
.body("icon_url", Matchers.isA(String.class)) | ||
.body("id", Matchers.isA(String.class)) | ||
.body("updated_at", Matchers.isA(String.class)) | ||
.body("url", Matchers.isA(String.class)) | ||
.body("value", Matchers.isA(String.class)); | ||
} | ||
|
||
@DisplayName("Should include CORS headers") | ||
@Test | ||
void shouldIncludeCORSHeaders() { | ||
var specification = given() | ||
.log().all() | ||
.accept("application/json") | ||
.header("Origin", "http://localhost:3000"); | ||
|
||
var response = specification.when().get("/jokes/random"); | ||
|
||
response.then() | ||
.log().all() | ||
.statusCode(200) | ||
.assertThat() | ||
.header("Access-Control-Allow-Origin", Matchers.equalTo("*")) | ||
.header("Access-Control-Expose-Headers", Matchers.equalTo("Access-Control-Allow-Origin Access-Control-Allow-Credentials")) | ||
.header("Content-Type", Matchers.equalTo("application/json")); | ||
} | ||
} |
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
Oops, something went wrong.