From 809a8d84c48564d92404d8d7d5e32d1f06e3c32b Mon Sep 17 00:00:00 2001 From: Szymon Szczubkowski Date: Sun, 21 Jan 2024 01:15:01 +0100 Subject: [PATCH] add: formats tests --- src/test/java/org/example/FormatsTest.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/java/org/example/FormatsTest.java diff --git a/src/test/java/org/example/FormatsTest.java b/src/test/java/org/example/FormatsTest.java new file mode 100644 index 0000000..ab629ee --- /dev/null +++ b/src/test/java/org/example/FormatsTest.java @@ -0,0 +1,27 @@ +package org.example; + +import io.restassured.RestAssured; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static io.restassured.RestAssured.when; +import static org.hamcrest.Matchers.hasSize; + +public class FormatsTest { + + @BeforeAll + public static void formatsTestSetup() { + RestAssured.baseURI = "https://api.magicthegathering.io/v1/formats"; + } + + @Test + public void getAllFormatsShouldReturnTwentyOneElements(){ + when().get().then().statusCode(200).body("formats", hasSize(21)); + } + + @Test + public void getFormatsWithInvalidPathParamShouldReturnErrorNotFound(){ + given().pathParam("id", 1).get("/{id}").then().statusCode(404); + } +}