View Main.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
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication | |
public class Main { | |
public static void main(String[] args) { | |
SpringApplication.run(Main.class, args); | |
} |
View YourApiService
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 org.example.services; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import io.restassured.RestAssured; | |
import io.restassured.builder.RequestSpecBuilder; | |
import io.restassured.http.ContentType; | |
import io.restassured.response.Response; | |
import io.restassured.specification.RequestSpecification; | |
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.stereotype.Service; |
View ApiTest
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.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import io.restassured.response.Response; | |
import org.example.services.YourApiService; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.TestInstance; | |
import org.junit.jupiter.api.extension.ExtendWith; |
View ApiTestAnnotation
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
@ExtendWith(SpringExtension.class) | |
@SpringBootTest | |
@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
View ApiTestConstructor
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
private final YourApiService yourApiService; | |
public ApiTest(YourApiService yourApiService) { | |
this.yourApiService = yourApiService; | |
} |
View TestCase
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
@Test | |
public void testCreateUser() throws JsonProcessingException { | |
ObjectMapper mapper = new ObjectMapper(); | |
String body = "{\"name\": \"Luiz Eduardo\", \"job\": \"Senior QA Engineer\"}"; | |
JsonNode requestBody = mapper.readTree(body); | |
} |
View FileUtils
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 org.example.repositories; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import org.springframework.stereotype.Repository; | |
import java.io.IOException; | |
import java.net.URL; | |
@Repository |
View createUser.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
{ | |
"name": "Luiz Eduardo", | |
"job": "Senior QA Engineer" | |
} |
View ApiTestV2
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; |
View ResponseUtils
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 org.example.repositories; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import io.restassured.response.Response; | |
import org.json.JSONException; | |
import org.skyscreamer.jsonassert.JSONAssert; | |
import org.skyscreamer.jsonassert.JSONCompareMode; | |
import org.springframework.stereotype.Repository; | |
@Repository |
OlderNewer