fixed merge conflicts
This commit is contained in:
parent
ff2cffa1f0
commit
e580d248df
|
@ -5,7 +5,6 @@
|
|||
<artifactId>rest-assured-tutorial</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>rest-assured</name>
|
||||
<<<<<<< HEAD
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -214,108 +213,38 @@
|
|||
<artifactId>wiremock</artifactId>
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
=======
|
||||
|
||||
<properties>
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
|
||||
<mockito.version>1.10.19</mockito.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<wiremock.version>2.1.7</wiremock.version>
|
||||
<hamcrest-all.version>1.3</hamcrest-all.version>
|
||||
<json-schema-core.version>1.2.5</json-schema-core.version>
|
||||
<json-schema-validator.version>2.2.6</json-schema-validator.version>
|
||||
<rest-assured.version>3.0.0</rest-assured.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.13</org.slf4j.version>
|
||||
<logback.version>1.1.3</logback.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- logging -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${org.slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
<!-- <scope>runtime</scope> -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${org.slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
<version>${org.slf4j.version}</version>
|
||||
</dependency>
|
||||
<!-- utils -->
|
||||
>>>>>>> upstream/master
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>${rest-assured.version}</version>
|
||||
<version>3.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-schema-validator</artifactId>
|
||||
<version>${rest-assured.version}</version>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.fge</groupId>
|
||||
<artifactId>json-schema-validator</artifactId>
|
||||
<version>${json-schema-validator.version}</version>
|
||||
<version>2.2.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.fge</groupId>
|
||||
<artifactId>json-schema-core</artifactId>
|
||||
<version>${json-schema-core.version}</version>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
<<<<<<< HEAD
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
=======
|
||||
|
||||
|
||||
<!-- test scoped -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
<version>${wiremock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
>>>>>>> upstream/master
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<version>${hamcrest-all.version}</version>
|
||||
<scope>test</scope>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->
|
||||
<dependency>
|
||||
|
@ -324,12 +253,5 @@
|
|||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,29 +1,14 @@
|
|||
package com.baeldung.restassured;
|
||||
|
||||
<<<<<<< HEAD
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.get;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
=======
|
||||
import com.github.fge.jsonschema.SchemaVersion;
|
||||
import com.github.fge.jsonschema.cfg.ValidationConfiguration;
|
||||
import com.github.fge.jsonschema.main.JsonSchemaFactory;
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
import io.restassured.module.jsv.JsonSchemaValidator;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
>>>>>>> upstream/master
|
||||
import static io.restassured.RestAssured.get;
|
||||
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
|
||||
import static io.restassured.module.jsv.JsonSchemaValidatorSettings.settings;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
<<<<<<< HEAD
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
|
||||
import org.junit.After;
|
||||
|
@ -34,10 +19,6 @@ import com.github.fge.jsonschema.SchemaVersion;
|
|||
import com.github.fge.jsonschema.cfg.ValidationConfiguration;
|
||||
import com.github.fge.jsonschema.main.JsonSchemaFactory;
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
=======
|
||||
import static org.hamcrest.xml.HasXPath.hasXPath;
|
||||
|
||||
>>>>>>> upstream/master
|
||||
|
||||
public class RestAssuredTest {
|
||||
|
||||
|
@ -63,91 +44,28 @@ public class RestAssuredTest {
|
|||
.body("odd.ck", equalTo(12.2f));
|
||||
}
|
||||
|
||||
private WireMockServer wireMockServer = new WireMockServer();
|
||||
private static final String EVENTS_PATH = "/events?id=390";
|
||||
private static final String APPLICATION_JSON = "application/json";
|
||||
|
||||
private static final String GAME_ODDS = "" +
|
||||
"{" +
|
||||
" \"id\": 390," +
|
||||
" \"data\": {" +
|
||||
" \"countryId\": 35," +
|
||||
" \"countryName\": \"Norway\"," +
|
||||
" \"leagueName\": \"Norway 3\"," +
|
||||
" \"status\": 0," +
|
||||
" \"sportName\": \"Soccer\"," +
|
||||
" \"time\": \"2016-06-12T12:00:00Z\"" +
|
||||
" }," +
|
||||
" \"odds\": [" +
|
||||
" {" +
|
||||
" \"price\": \"1.30\"," +
|
||||
" \"status\": 0," +
|
||||
" \"ck\": \"1\"," +
|
||||
" \"name\": \"1\"" +
|
||||
" }," +
|
||||
" {" +
|
||||
" \"price\": \"5.25\"," +
|
||||
" \"status\": 0," +
|
||||
" \"ck\": \"X\"," +
|
||||
" \"name\": \"X\"" +
|
||||
" }" +
|
||||
" ]" +
|
||||
"}";
|
||||
|
||||
|
||||
@Test
|
||||
public void givenUrl_whenSuccessOnGetsResponse_andJsonHasRequiredKV_thenCorrect() {
|
||||
|
||||
wireMockServer.start();
|
||||
configureFor("localhost", 8080);
|
||||
|
||||
stubFor(WireMock.get(urlEqualTo(EVENTS_PATH)).willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", APPLICATION_JSON)
|
||||
.withBody(GAME_ODDS)));
|
||||
public void givenUrl_whenSuccessOnGetsResponse_andJsonHasRequiredKV_thenCorrect() {
|
||||
|
||||
get("/events?id=390").then().statusCode(200).assertThat()
|
||||
<<<<<<< HEAD
|
||||
.body("id", equalTo("390"));
|
||||
=======
|
||||
.body("id", equalTo(390));
|
||||
>>>>>>> upstream/master
|
||||
|
||||
wireMockServer.stop();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenUrl_whenJsonResponseHasArrayWithGivenValuesUnderKey_thenCorrect() {
|
||||
<<<<<<< HEAD
|
||||
get("/events?id=390").then().assertThat()
|
||||
.body("odds.price", hasItems(1.30f, 5.25f, 2.70f, 1.20f));
|
||||
=======
|
||||
|
||||
wireMockServer.start();
|
||||
configureFor("localhost", 8080);
|
||||
|
||||
stubFor(WireMock.get(urlEqualTo(EVENTS_PATH)).willReturn(aResponse()
|
||||
.withStatus(200)
|
||||
.withHeader("Content-Type", APPLICATION_JSON)
|
||||
.withBody(GAME_ODDS)));
|
||||
|
||||
get("/events?id=390").then().assertThat()
|
||||
.body("odds.price", hasItems("1.30", "5.25"));
|
||||
|
||||
wireMockServer.stop();
|
||||
>>>>>>> upstream/master
|
||||
}
|
||||
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
public void givenUrl_whenJsonResponseConformsToSchema_thenCorrect() {
|
||||
|
||||
get("/events?id=390").then().assertThat()
|
||||
.body(matchesJsonSchemaInClasspath("event_0.json"));
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
public void givenUrl_whenValidatesResponseWithInstanceSettings_thenCorrect() {
|
||||
JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory
|
||||
.newBuilder()
|
||||
|
@ -164,11 +82,10 @@ public class RestAssuredTest {
|
|||
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
public void givenUrl_whenValidatesResponseWithStaticSettings_thenCorrect() {
|
||||
|
||||
get("/events?id=390")
|
||||
<<<<<<< HEAD
|
||||
.then()
|
||||
.assertThat()
|
||||
.body(matchesJsonSchemaInClasspath("event_0.json").using(
|
||||
|
@ -184,75 +101,6 @@ public class RestAssuredTest {
|
|||
private static String getEventJson() {
|
||||
return Util.inputStreamToString(new RestAssuredTest().getClass()
|
||||
.getResourceAsStream("/event_0.json"));
|
||||
=======
|
||||
.then()
|
||||
.assertThat()
|
||||
.body(matchesJsonSchemaInClasspath("event_0.json").using(
|
||||
settings().with().checkedValidation(false)));
|
||||
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenCheckingFloatValuePasses_thenCorrect() {
|
||||
get("/odd").then().assertThat().body("odd.ck", equalTo(12.2f));
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenXmlResponseValueTestsEqual_thenCorrect() {
|
||||
post("/employees").then().assertThat()
|
||||
.body("employees.employee.first-name", equalTo("Jane"));
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenMultipleXmlValuesTestEqual_thenCorrect() {
|
||||
post("/employees").then().assertThat()
|
||||
.body("employees.employee.first-name", equalTo("Jane"))
|
||||
.body("employees.employee.last-name", equalTo("Daisy"))
|
||||
.body("employees.employee.sex", equalTo("f"));
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenMultipleXmlValuesTestEqualInShortHand_thenCorrect() {
|
||||
post("/employees")
|
||||
.then()
|
||||
.assertThat()
|
||||
.body("employees.employee.first-name", equalTo("Jane"),
|
||||
"employees.employee.last-name", equalTo("Daisy"),
|
||||
"employees.employee.sex", equalTo("f"));
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenValidatesXmlUsingXpath_thenCorrect() {
|
||||
post("/employees")
|
||||
.then()
|
||||
.assertThat()
|
||||
.body(hasXPath("/employees/employee/first-name",
|
||||
containsString("Ja")));
|
||||
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenValidatesXmlUsingXpath2_thenCorrect() {
|
||||
post("/employees")
|
||||
.then()
|
||||
.assertThat()
|
||||
.body(hasXPath("/employees/employee/first-name[text()='Jane']"));
|
||||
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenVerifiesScienceTeacherFromXml_thenCorrect() {
|
||||
get("/teachers")
|
||||
.then()
|
||||
.body("teachers.teacher.find { it.@department == 'science' }.subject",
|
||||
hasItems("math", "physics"));
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void givenUrl_whenVerifiesOddPricesAccuratelyByStatus_thenCorrect() {
|
||||
get("/odds").then().body("odds.findAll { it.status > 0 }.price",
|
||||
hasItems(1.30f, 1.20f));
|
||||
>>>>>>> upstream/master
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue