Skip to content

Commit e580d24

Browse files
committed
fixed merge conflicts
1 parent ff2cffa commit e580d24

2 files changed

Lines changed: 9 additions & 239 deletions

File tree

‎rest-assured-tutorial/pom.xml‎

Lines changed: 5 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<artifactId>rest-assured-tutorial</artifactId>
66
<version>1.0</version>
77
<name>rest-assured</name>
8-
<<<<<<< HEAD
98
<build>
109
<plugins>
1110
<plugin>
@@ -214,108 +213,38 @@
214213
<artifactId>wiremock</artifactId>
215214
<version>2.1.7</version>
216215
</dependency>
217-
=======
218-
219-
<properties>
220-
<!-- maven plugins -->
221-
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
222-
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
223-
224-
<mockito.version>1.10.19</mockito.version>
225-
<junit.version>4.12</junit.version>
226-
<wiremock.version>2.1.7</wiremock.version>
227-
<hamcrest-all.version>1.3</hamcrest-all.version>
228-
<json-schema-core.version>1.2.5</json-schema-core.version>
229-
<json-schema-validator.version>2.2.6</json-schema-validator.version>
230-
<rest-assured.version>3.0.0</rest-assured.version>
231-
232-
<!-- logging -->
233-
<org.slf4j.version>1.7.13</org.slf4j.version>
234-
<logback.version>1.1.3</logback.version>
235-
</properties>
236-
237-
<dependencies>
238-
<!-- logging -->
239-
240-
<dependency>
241-
<groupId>org.slf4j</groupId>
242-
<artifactId>slf4j-api</artifactId>
243-
<version>${org.slf4j.version}</version>
244-
</dependency>
245-
<dependency>
246-
<groupId>ch.qos.logback</groupId>
247-
<artifactId>logback-classic</artifactId>
248-
<version>${logback.version}</version>
249-
<!-- <scope>runtime</scope> -->
250-
</dependency>
251-
<dependency>
252-
<groupId>org.slf4j</groupId>
253-
<artifactId>jcl-over-slf4j</artifactId>
254-
<version>${org.slf4j.version}</version>
255-
<scope>runtime</scope>
256-
</dependency>
257-
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
258-
<groupId>org.slf4j</groupId>
259-
<artifactId>log4j-over-slf4j</artifactId>
260-
<version>${org.slf4j.version}</version>
261-
</dependency>
262-
<!-- utils -->
263-
>>>>>>> upstream/master
264216
<dependency>
265217
<groupId>io.rest-assured</groupId>
266218
<artifactId>rest-assured</artifactId>
267-
<version>${rest-assured.version}</version>
219+
<version>3.0.0</version>
268220
<scope>test</scope>
269221
</dependency>
270-
271222
<dependency>
272223
<groupId>io.rest-assured</groupId>
273224
<artifactId>json-schema-validator</artifactId>
274-
<version>${rest-assured.version}</version>
225+
<version>3.0.0</version>
275226
</dependency>
276-
277227
<dependency>
278228
<groupId>com.github.fge</groupId>
279229
<artifactId>json-schema-validator</artifactId>
280-
<version>${json-schema-validator.version}</version>
230+
<version>2.2.6</version>
281231
</dependency>
282-
283232
<dependency>
284233
<groupId>com.github.fge</groupId>
285234
<artifactId>json-schema-core</artifactId>
286-
<version>${json-schema-core.version}</version>
235+
<version>1.2.5</version>
287236
</dependency>
288-
<<<<<<< HEAD
289237
<dependency>
290238
<groupId>junit</groupId>
291239
<artifactId>junit</artifactId>
292240
<version>4.3</version>
293241
<scope>test</scope>
294242
</dependency>
295-
=======
296-
297-
298-
<!-- test scoped -->
299-
<dependency>
300-
<groupId>junit</groupId>
301-
<artifactId>junit</artifactId>
302-
<version>${junit.version}</version>
303-
<scope>test</scope>
304-
</dependency>
305-
306-
<dependency>
307-
<groupId>com.github.tomakehurst</groupId>
308-
<artifactId>wiremock</artifactId>
309-
<version>${wiremock.version}</version>
310-
<scope>test</scope>
311-
</dependency>
312-
>>>>>>> upstream/master
313243

314244
<dependency>
315245
<groupId>org.hamcrest</groupId>
316246
<artifactId>hamcrest-all</artifactId>
317-
<version>${hamcrest-all.version}</version>
318-
<scope>test</scope>
247+
<version>1.3</version>
319248
</dependency>
320249
<!-- https://mvnrepository.com/artifact/commons-collections/commons-collections -->
321250
<dependency>
@@ -324,12 +253,5 @@
324253
<version>3.2.2</version>
325254
</dependency>
326255

327-
<dependency>
328-
<groupId>org.mockito</groupId>
329-
<artifactId>mockito-core</artifactId>
330-
<version>${mockito.version}</version>
331-
<scope>test</scope>
332-
</dependency>
333-
334256
</dependencies>
335257
</project>
Lines changed: 4 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
package com.baeldung.restassured;
22

3-
<<<<<<< HEAD
43
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
54
import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
65
import static com.github.tomakehurst.wiremock.client.WireMock.get;
76
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
87
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
9-
=======
10-
import com.github.fge.jsonschema.SchemaVersion;
11-
import com.github.fge.jsonschema.cfg.ValidationConfiguration;
12-
import com.github.fge.jsonschema.main.JsonSchemaFactory;
13-
import com.github.tomakehurst.wiremock.WireMockServer;
14-
import com.github.tomakehurst.wiremock.client.WireMock;
15-
import io.restassured.module.jsv.JsonSchemaValidator;
16-
import org.junit.Ignore;
17-
import org.junit.Test;
18-
19-
import static com.github.tomakehurst.wiremock.client.WireMock.*;
20-
>>>>>>> upstream/master
218
import static io.restassured.RestAssured.get;
229
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
2310
import static io.restassured.module.jsv.JsonSchemaValidatorSettings.settings;
24-
import static org.hamcrest.Matchers.*;
2511
import static org.hamcrest.Matchers.equalTo;
26-
<<<<<<< HEAD
2712
import static org.hamcrest.Matchers.hasItems;
2813

2914
import org.junit.After;
@@ -34,10 +19,6 @@
3419
import com.github.fge.jsonschema.cfg.ValidationConfiguration;
3520
import com.github.fge.jsonschema.main.JsonSchemaFactory;
3621
import com.github.tomakehurst.wiremock.WireMockServer;
37-
=======
38-
import static org.hamcrest.xml.HasXPath.hasXPath;
39-
40-
>>>>>>> upstream/master
4122

4223
public class RestAssuredTest {
4324

@@ -63,91 +44,28 @@ public void givenUrl_whenCheckingFloatValuePasses_thenCorrect() {
6344
.body("odd.ck", equalTo(12.2f));
6445
}
6546

66-
private WireMockServer wireMockServer = new WireMockServer();
67-
private static final String EVENTS_PATH = "/events?id=390";
68-
private static final String APPLICATION_JSON = "application/json";
69-
70-
private static final String GAME_ODDS = "" +
71-
"{" +
72-
" \"id\": 390," +
73-
" \"data\": {" +
74-
" \"countryId\": 35," +
75-
" \"countryName\": \"Norway\"," +
76-
" \"leagueName\": \"Norway 3\"," +
77-
" \"status\": 0," +
78-
" \"sportName\": \"Soccer\"," +
79-
" \"time\": \"2016-06-12T12:00:00Z\"" +
80-
" }," +
81-
" \"odds\": [" +
82-
" {" +
83-
" \"price\": \"1.30\"," +
84-
" \"status\": 0," +
85-
" \"ck\": \"1\"," +
86-
" \"name\": \"1\"" +
87-
" }," +
88-
" {" +
89-
" \"price\": \"5.25\"," +
90-
" \"status\": 0," +
91-
" \"ck\": \"X\"," +
92-
" \"name\": \"X\"" +
93-
" }" +
94-
" ]" +
95-
"}";
96-
97-
9847
@Test
99-
public void givenUrl_whenSuccessOnGetsResponse_andJsonHasRequiredKV_thenCorrect() {
100-
101-
wireMockServer.start();
102-
configureFor("localhost", 8080);
103-
104-
stubFor(WireMock.get(urlEqualTo(EVENTS_PATH)).willReturn(aResponse()
105-
.withStatus(200)
106-
.withHeader("Content-Type", APPLICATION_JSON)
107-
.withBody(GAME_ODDS)));
48+
public void givenUrl_whenSuccessOnGetsResponse_andJsonHasRequiredKV_thenCorrect() {
10849

10950
get("/events?id=390").then().statusCode(200).assertThat()
110-
<<<<<<< HEAD
11151
.body("id", equalTo("390"));
112-
=======
113-
.body("id", equalTo(390));
114-
>>>>>>> upstream/master
11552

116-
wireMockServer.stop();
11753
}
11854

119-
12055
@Test
12156
public void givenUrl_whenJsonResponseHasArrayWithGivenValuesUnderKey_thenCorrect() {
122-
<<<<<<< HEAD
12357
get("/events?id=390").then().assertThat()
12458
.body("odds.price", hasItems(1.30f, 5.25f, 2.70f, 1.20f));
125-
=======
126-
127-
wireMockServer.start();
128-
configureFor("localhost", 8080);
129-
130-
stubFor(WireMock.get(urlEqualTo(EVENTS_PATH)).willReturn(aResponse()
131-
.withStatus(200)
132-
.withHeader("Content-Type", APPLICATION_JSON)
133-
.withBody(GAME_ODDS)));
134-
135-
get("/events?id=390").then().assertThat()
136-
.body("odds.price", hasItems("1.30", "5.25"));
137-
138-
wireMockServer.stop();
139-
>>>>>>> upstream/master
14059
}
14160

142-
143-
@Test @Ignore
61+
@Test
14462
public void givenUrl_whenJsonResponseConformsToSchema_thenCorrect() {
14563

14664
get("/events?id=390").then().assertThat()
14765
.body(matchesJsonSchemaInClasspath("event_0.json"));
14866
}
14967

150-
@Test @Ignore
68+
@Test
15169
public void givenUrl_whenValidatesResponseWithInstanceSettings_thenCorrect() {
15270
JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory
15371
.newBuilder()
@@ -164,11 +82,10 @@ public void givenUrl_whenValidatesResponseWithInstanceSettings_thenCorrect() {
16482

16583
}
16684

167-
@Test @Ignore
85+
@Test
16886
public void givenUrl_whenValidatesResponseWithStaticSettings_thenCorrect() {
16987

17088
get("/events?id=390")
171-
<<<<<<< HEAD
17289
.then()
17390
.assertThat()
17491
.body(matchesJsonSchemaInClasspath("event_0.json").using(
@@ -184,75 +101,6 @@ public void after() throws Exception {
184101
private static String getEventJson() {
185102
return Util.inputStreamToString(new RestAssuredTest().getClass()
186103
.getResourceAsStream("/event_0.json"));
187-
=======
188-
.then()
189-
.assertThat()
190-
.body(matchesJsonSchemaInClasspath("event_0.json").using(
191-
settings().with().checkedValidation(false)));
192-
193-
}
194-
195-
@Test @Ignore
196-
public void givenUrl_whenCheckingFloatValuePasses_thenCorrect() {
197-
get("/odd").then().assertThat().body("odd.ck", equalTo(12.2f));
198-
}
199-
200-
@Test @Ignore
201-
public void givenUrl_whenXmlResponseValueTestsEqual_thenCorrect() {
202-
post("/employees").then().assertThat()
203-
.body("employees.employee.first-name", equalTo("Jane"));
204-
}
205-
206-
@Test @Ignore
207-
public void givenUrl_whenMultipleXmlValuesTestEqual_thenCorrect() {
208-
post("/employees").then().assertThat()
209-
.body("employees.employee.first-name", equalTo("Jane"))
210-
.body("employees.employee.last-name", equalTo("Daisy"))
211-
.body("employees.employee.sex", equalTo("f"));
212-
}
213-
214-
@Test @Ignore
215-
public void givenUrl_whenMultipleXmlValuesTestEqualInShortHand_thenCorrect() {
216-
post("/employees")
217-
.then()
218-
.assertThat()
219-
.body("employees.employee.first-name", equalTo("Jane"),
220-
"employees.employee.last-name", equalTo("Daisy"),
221-
"employees.employee.sex", equalTo("f"));
222-
}
223-
224-
@Test @Ignore
225-
public void givenUrl_whenValidatesXmlUsingXpath_thenCorrect() {
226-
post("/employees")
227-
.then()
228-
.assertThat()
229-
.body(hasXPath("/employees/employee/first-name",
230-
containsString("Ja")));
231-
232-
}
233-
234-
@Test @Ignore
235-
public void givenUrl_whenValidatesXmlUsingXpath2_thenCorrect() {
236-
post("/employees")
237-
.then()
238-
.assertThat()
239-
.body(hasXPath("/employees/employee/first-name[text()='Jane']"));
240-
241-
}
242-
243-
@Test @Ignore
244-
public void givenUrl_whenVerifiesScienceTeacherFromXml_thenCorrect() {
245-
get("/teachers")
246-
.then()
247-
.body("teachers.teacher.find { it.@department == 'science' }.subject",
248-
hasItems("math", "physics"));
249-
}
250-
251-
@Test @Ignore
252-
public void givenUrl_whenVerifiesOddPricesAccuratelyByStatus_thenCorrect() {
253-
get("/odds").then().body("odds.findAll { it.status > 0 }.price",
254-
hasItems(1.30f, 1.20f));
255-
>>>>>>> upstream/master
256104
}
257105

258106
}

0 commit comments

Comments
 (0)