Skip to content

Commit 5693c9a

Browse files
committed
Added Delete Book method
1 parent 17ada78 commit 5693c9a

File tree

12 files changed

+82
-23
lines changed

12 files changed

+82
-23
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
<artifactId>jackson-databind</artifactId>
2424
<version>2.18.2</version>
2525
</dependency>
26+
<dependency>
27+
<groupId>org.hamcrest</groupId>
28+
<artifactId>hamcrest</artifactId>
29+
<version>3.0</version>
30+
<scope>test</scope>
31+
</dependency>
2632
<dependency>
2733
<groupId>org.apache.poi</groupId>
2834
<artifactId>poi</artifactId>

src/test/java/Tests/LibraryAPI.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
import io.restassured.http.ContentType;
99
import io.restassured.path.json.JsonPath;
1010
import static io.restassured.RestAssured.*;
11+
import static org.hamcrest.Matchers.*;
1112
import utilities.ReadDataFromExcel;
1213

1314
public class LibraryAPI
1415
{
16+
String bookID;
1517
@Test
1618
public void addBook() throws IOException
1719
{
@@ -27,8 +29,21 @@ public void addBook() throws IOException
2729
RestAssured.baseURI="http://216.10.245.166";
2830
String addBookResponse=given().log().all().contentType(ContentType.JSON).body(jsonBody)
2931
.when().post("Library/Addbook.php")
30-
.then().log().all().assertThat().statusCode(200).extract().response().asString();
32+
.then().log().all().assertThat().statusCode(200).body("Msg", equalTo("successfully added")).extract().response().asString();
33+
3134
JsonPath js=new JsonPath(addBookResponse);
32-
System.out.println(js.getString("ID"));
35+
bookID=js.getString("ID");
36+
}
37+
38+
@Test
39+
public void deleteBook()
40+
{
41+
HashMap <String, Object> jsonBody=new HashMap<>();
42+
jsonBody.put("ID", bookID);
43+
44+
RestAssured.baseURI="http://216.10.245.166";
45+
String deleteBookResponse=given().log().all().contentType(ContentType.JSON).body(jsonBody)
46+
.when().delete("Library/DeleteBook.php")
47+
.then().log().all().assertThat().statusCode(200).body("msg", equalTo("book is successfully deleted")).extract().response().asString();
3348
}
3449
}

target/classes/META-INF/maven/ExcelReadingRestAssured/ExcelReadingRestAssured/pom.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Generated by Maven Integration for Eclipse
2-
#Thu Jan 09 11:04:19 IST 2025
2+
#Thu Jan 09 11:31:04 IST 2025
33
artifactId=ExcelReadingRestAssured
44
groupId=ExcelReadingRestAssured
55
m2e.projectLocation=C\:\\Users\\Sayan Ghosh Dastidar\\RestAssuredLearning\\RestAssuredFrameworkExcelData

target/classes/META-INF/maven/ExcelReadingRestAssured/ExcelReadingRestAssured/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
<artifactId>jackson-databind</artifactId>
2424
<version>2.18.2</version>
2525
</dependency>
26+
<dependency>
27+
<groupId>org.hamcrest</groupId>
28+
<artifactId>hamcrest</artifactId>
29+
<version>3.0</version>
30+
<scope>test</scope>
31+
</dependency>
2632
<dependency>
2733
<groupId>org.apache.poi</groupId>
2834
<artifactId>poi</artifactId>
598 Bytes
Binary file not shown.

test-output/Default suite/Default test.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
<body>
5656
<h2 align='center'>Default test</h2><table border='1' align="center">
5757
<tr>
58-
<td>Tests passed/Failed/Skipped:</td><td>1/0/0</td>
58+
<td>Tests passed/Failed/Skipped:</td><td>2/0/0</td>
5959
</tr><tr>
60-
<td>Started on:</td><td>Thu Jan 09 11:12:33 IST 2025</td>
60+
<td>Started on:</td><td>Thu Jan 09 11:33:37 IST 2025</td>
6161
</tr>
62-
<tr><td>Total time:</td><td>3 seconds (3316 ms)</td>
62+
<tr><td>Total time:</td><td>3 seconds (3286 ms)</td>
6363
</tr><tr>
6464
<td>Included groups:</td><td></td>
6565
</tr><tr>
@@ -78,8 +78,13 @@ <h2 align='center'>Default test</h2><table border='1' align="center">
7878
<tr>
7979
<td title='tests.LibraryAPI.addBook()'><b>addBook</b><br>Test class: tests.LibraryAPI</td>
8080
<td></td>
81-
<td>3</td>
82-
<td>tests.LibraryAPI@79e2c065</td></tr>
81+
<td>2</td>
82+
<td>tests.LibraryAPI@3a93b025</td></tr>
83+
<tr>
84+
<td title='tests.LibraryAPI.deleteBook()'><b>deleteBook</b><br>Test class: tests.LibraryAPI</td>
85+
<td></td>
86+
<td>0</td>
87+
<td>tests.LibraryAPI@3a93b025</td></tr>
8388
</table><p>
8489
</body>
8590
</html>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!-- Generated by org.testng.reporters.JUnitXMLReporter -->
3-
<testsuite ignored="0" hostname="LAPTOP-4TAGSQNH" failures="0" tests="1" name="Default test" time="3.316" errors="0" timestamp="2025-01-09T11:12:37 IST">
4-
<testcase classname="tests.LibraryAPI" name="addBook" time="3.277"/>
3+
<testsuite ignored="0" hostname="LAPTOP-4TAGSQNH" failures="0" tests="2" name="Default test" time="3.286" errors="0" timestamp="2025-01-09T11:33:41 IST">
4+
<testcase classname="tests.LibraryAPI" name="addBook" time="2.958"/>
5+
<testcase classname="tests.LibraryAPI" name="deleteBook" time="0.274"/>
56
</testsuite> <!-- Default test -->

test-output/emailable-report.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
<table>
1010
<tr><th>Test</th><th># Passed</th><th># Skipped</th><th># Retried</th><th># Failed</th><th>Time (ms)</th><th>Included Groups</th><th>Excluded Groups</th></tr>
1111
<tr><th colspan="8">Default suite</th></tr>
12-
<tr><td><a href="#t0">Default test</a></td><td class="num">1</td><td class="num">0</td><td class="num">0</td><td class="num">0</td><td class="num">3,316</td><td></td><td></td></tr>
12+
<tr><td><a href="#t0">Default test</a></td><td class="num">2</td><td class="num">0</td><td class="num">0</td><td class="num">0</td><td class="num">3,286</td><td></td><td></td></tr>
1313
</table>
14-
<table id='summary'><thead><tr><th>Class</th><th>Method</th><th>Start</th><th>Time (ms)</th></tr></thead><tbody><tr><th colspan="4">Default suite</th></tr></tbody><tbody id="t0"><tr><th colspan="4">Default test &#8212; passed</th></tr><tr class="passedeven"><td rowspan="1">tests.LibraryAPI</td><td><a href="#m0">addBook</a></td><td rowspan="1">1736401353893</td><td rowspan="1">3277</td></tr></tbody>
14+
<table id='summary'><thead><tr><th>Class</th><th>Method</th><th>Start</th><th>Time (ms)</th></tr></thead><tbody><tr><th colspan="4">Default suite</th></tr></tbody><tbody id="t0"><tr><th colspan="4">Default test &#8212; passed</th></tr><tr class="passedeven"><td rowspan="2">tests.LibraryAPI</td><td><a href="#m0">addBook</a></td><td rowspan="1">1736402617938</td><td rowspan="1">2958</td></tr><tr class="passedeven"><td><a href="#m1">deleteBook</a></td><td rowspan="1">1736402620900</td><td rowspan="1">274</td></tr></tbody>
1515
</table>
1616
<h2>Default test</h2><h3 id="m0">tests.LibraryAPI#addBook</h3><table class="result"><tr><th class="invisible"/></tr></table><p class="totop"><a href="#summary">back to summary</a></p>
17+
<h3 id="m1">tests.LibraryAPI#deleteBook</h3><table class="result"><tr><th class="invisible"/></tr></table><p class="totop"><a href="#summary">back to summary</a></p>
1718
</body>
1819
</html>

test-output/index.html

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<ul>
5151
<li>
5252
<a href="#" panel-name="test-xml-Default_suite" class="navigator-link ">
53-
<span>C:\Users\Sayan Ghosh Dastidar\AppData\Local\Temp\testng-eclipse--1076025374\testng-customsuite.xml</span>
53+
<span>C:\Users\Sayan Ghosh Dastidar\AppData\Local\Temp\testng-eclipse--1914767062\testng-customsuite.xml</span>
5454
</a> <!-- navigator-link -->
5555
</li>
5656
<li>
@@ -92,7 +92,7 @@
9292
<div class="suite-section-content">
9393
<ul>
9494
<li>
95-
<span class="method-stats">1 method, 1 passed</span>
95+
<span class="method-stats">2 methods, 2 passed</span>
9696
</li>
9797
<li>
9898
<span class="method-list-title passed">Passed methods</span>
@@ -106,6 +106,11 @@
106106
<a href="#" panel-name="suite-Default_suite" title="tests.LibraryAPI" class="method navigator-link" hash-for-method="addBook">addBook</a> <!-- method navigator-link -->
107107
</span>
108108
<br/>
109+
<span>
110+
<img src="passed.png" width="3%"/>
111+
<a href="#" panel-name="suite-Default_suite" title="tests.LibraryAPI" class="method navigator-link" hash-for-method="deleteBook">deleteBook</a> <!-- method navigator-link -->
112+
</span>
113+
<br/>
109114
</div> <!-- method-list-content passed suite-Default_suite -->
110115
</li>
111116
</ul>
@@ -131,12 +136,19 @@
131136
<span class="method-name">addBook</span>
132137
</div> <!-- method-content -->
133138
</div> <!-- method -->
139+
<div class="method">
140+
<div class="method-content">
141+
<a name="deleteBook">
142+
</a> <!-- deleteBook -->
143+
<span class="method-name">deleteBook</span>
144+
</div> <!-- method-content -->
145+
</div> <!-- method -->
134146
</div> <!-- main-panel-content rounded-window-bottom -->
135147
</div> <!-- suite-Default_suite-class-passed -->
136148
</div> <!-- panel Default_suite -->
137149
<div panel-name="test-xml-Default_suite" class="panel">
138150
<div class="main-panel-header rounded-window-top">
139-
<span class="header-content">C:\Users\Sayan Ghosh Dastidar\AppData\Local\Temp\testng-eclipse--1076025374\testng-customsuite.xml</span>
151+
<span class="header-content">C:\Users\Sayan Ghosh Dastidar\AppData\Local\Temp\testng-eclipse--1914767062\testng-customsuite.xml</span>
140152
</div> <!-- main-panel-header rounded-window-top -->
141153
<div class="main-panel-content rounded-window-bottom">
142154
<pre>
@@ -185,11 +197,15 @@
185197
data.addColumn('string', 'Method');
186198
data.addColumn('string', 'Class');
187199
data.addColumn('number', 'Time (ms)');
188-
data.addRows(1);
200+
data.addRows(2);
189201
data.setCell(0, 0, 0)
190202
data.setCell(0, 1, 'addBook')
191203
data.setCell(0, 2, 'tests.LibraryAPI')
192-
data.setCell(0, 3, 3277);
204+
data.setCell(0, 3, 2958);
205+
data.setCell(1, 0, 1)
206+
data.setCell(1, 1, 'deleteBook')
207+
data.setCell(1, 2, 'tests.LibraryAPI')
208+
data.setCell(1, 3, 274);
193209
window.suiteTableData['Default_suite']= { tableData: data, tableDiv: 'times-div-Default_suite'}
194210
return data;
195211
}
@@ -225,6 +241,10 @@
225241
<span class="method-name">addBook</span>
226242
<span class="method-start">0 ms</span>
227243
</div> <!-- test-method -->
244+
<div class="test-method">
245+
<span class="method-name">deleteBook</span>
246+
<span class="method-start">2962 ms</span>
247+
</div> <!-- test-method -->
228248
</div> <!-- main-panel-content rounded-window-bottom -->
229249
</div> <!-- panel -->
230250
</div> <!-- main-panel-root -->
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!-- Generated by org.testng.reporters.JUnitReportReporter -->
3-
<testsuite hostname="LAPTOP-4TAGSQNH" failures="0" tests="1" name="tests.LibraryAPI" time="3.277" errors="0" timestamp="2025-01-09T11:12:37 IST" skipped="0">
4-
<testcase classname="tests.LibraryAPI" name="addBook" time="3.277"/>
3+
<testsuite hostname="LAPTOP-4TAGSQNH" failures="0" tests="2" name="tests.LibraryAPI" time="3.232" errors="0" timestamp="2025-01-09T11:33:41 IST" skipped="0">
4+
<testcase classname="tests.LibraryAPI" name="addBook" time="2.958"/>
5+
<testcase classname="tests.LibraryAPI" name="deleteBook" time="0.274"/>
56
</testsuite> <!-- tests.LibraryAPI -->

test-output/testng-results.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testng-results ignored="0" total="1" passed="1" failed="0" skipped="0">
2+
<testng-results ignored="0" total="2" passed="2" failed="0" skipped="0">
33
<reporter-output>
44
</reporter-output>
5-
<suite started-at="2025-01-09T11:12:33 IST" name="Default suite" finished-at="2025-01-09T11:12:37 IST" duration-ms="3316">
5+
<suite started-at="2025-01-09T11:33:37 IST" name="Default suite" finished-at="2025-01-09T11:33:41 IST" duration-ms="3286">
66
<groups>
77
</groups>
8-
<test started-at="2025-01-09T11:12:33 IST" name="Default test" finished-at="2025-01-09T11:12:37 IST" duration-ms="3316">
8+
<test started-at="2025-01-09T11:33:37 IST" name="Default test" finished-at="2025-01-09T11:33:41 IST" duration-ms="3286">
99
<class name="tests.LibraryAPI">
10-
<test-method signature="addBook()[pri:0, instance:tests.LibraryAPI@79e2c065]" started-at="2025-01-09T11:12:33 IST" name="addBook" finished-at="2025-01-09T11:12:37 IST" duration-ms="3277" status="PASS">
10+
<test-method signature="addBook()[pri:0, instance:tests.LibraryAPI@3a93b025]" started-at="2025-01-09T11:33:37 IST" name="addBook" finished-at="2025-01-09T11:33:40 IST" duration-ms="2958" status="PASS">
1111
<reporter-output>
1212
</reporter-output>
1313
</test-method> <!-- addBook -->
14+
<test-method signature="deleteBook()[pri:0, instance:tests.LibraryAPI@3a93b025]" started-at="2025-01-09T11:33:40 IST" name="deleteBook" finished-at="2025-01-09T11:33:41 IST" duration-ms="274" status="PASS">
15+
<reporter-output>
16+
</reporter-output>
17+
</test-method> <!-- deleteBook -->
1418
</class> <!-- tests.LibraryAPI -->
1519
</test> <!-- Default test -->
1620
</suite> <!-- Default suite -->

testdata.xlsx

-1 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)