Created
December 26, 2024 18:36
-
-
Save borodicht/c68cec8e0b8ac3cd828c83e76306d04c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package adapters; | |
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; | |
import com.sun.net.httpserver.Request; | |
import io.restassured.http.ContentType; | |
import io.restassured.specification.RequestSpecification; | |
import models.CreateProjectRq; | |
import models.CreateProjectRs; | |
import static io.restassured.RestAssured.given; | |
public class ProjectAPI { | |
public static String token = "71d822c4c3d4718cf555e793a75c65710f3397cb84af11138828649e8273f4bb"; | |
public static Gson gson = new GsonBuilder() | |
.excludeFieldsWithoutExposeAnnotation() | |
.create(); | |
public static RequestSpecification spec = | |
given() | |
.log().all() | |
.contentType(ContentType.JSON) | |
.header("Token", token); | |
public static CreateProjectRs createProject(CreateProjectRq createProjectRq) { | |
return | |
given() | |
.spec(spec) | |
.body(gson.toJson(createProjectRq)) | |
.when() | |
.post("https://api.qase.io/v1/project") | |
.then() | |
.log().all() | |
.statusCode(200) | |
.extract() | |
.as(CreateProjectRs.class); | |
} | |
public static void deleteProject(String code) { | |
given() | |
.spec(spec) | |
.when() | |
.delete("https://api.qase.io/v1/project/" + code) | |
.then() | |
.log().all() | |
.statusCode(200); | |
} | |
} |
This file contains hidden or 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
package tests; | |
import adapters.ProjectAPI; | |
import io.restassured.http.ContentType; | |
import models.CreateProjectRq; | |
import models.CreateProjectRs; | |
import org.testng.Assert; | |
import org.testng.annotations.Test; | |
import static adapters.ProjectAPI.*; | |
import static io.restassured.RestAssured.given; | |
public class ProjectTest { | |
@Test | |
public void checkCreateProject() { | |
CreateProjectRq rq = CreateProjectRq.builder() | |
.title("QA Test2") | |
.code("QA2") | |
.description("Test") | |
.build(); | |
CreateProjectRs rs = createProject(rq); | |
Assert.assertEquals(rs.getStatus(), true); | |
Assert.assertEquals(rs.getResult().getCode(), "QA2"); | |
deleteProject("QA2"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment