Last active
October 21, 2022 15:55
-
-
Save luuizeduardo/48d88925dd9541913f4c5aace81d620c to your computer and use it in GitHub Desktop.
Improve the object mapping
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
package api.test.java.tests; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import io.restassured.response.Response; | |
import org.example.repositories.FileUtils; | |
import org.example.services.YourApiService; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.TestInstance; | |
import org.junit.jupiter.api.extension.ExtendWith; | |
import org.springframework.boot.test.context.SpringBootTest; | |
import org.springframework.test.context.junit.jupiter.SpringExtension; | |
import java.io.IOException; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
import static org.hamcrest.Matchers.equalTo; | |
import static org.hamcrest.Matchers.is; | |
@ExtendWith(SpringExtension.class) | |
@SpringBootTest | |
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | |
public class ApiTest { | |
private final YourApiService yourApiService; | |
public ApiTest(YourApiService yourApiService) { | |
this.yourApiService = yourApiService; | |
} | |
@Test | |
public void testCreateUser() throws IOException { | |
JsonNode requestBody = FileUtils.readJsonFromFile("user/createUser.json"); | |
Response res = yourApiService.postRequest("/users", requestBody); | |
assertThat(res.statusCode(), is(equalTo(201))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment