-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCreateIncidentUsingFiles.java
More file actions
60 lines (40 loc) · 1.39 KB
/
CreateIncidentUsingFiles.java
File metadata and controls
60 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package day1;
import java.io.File;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.authentication.AuthenticationScheme;
import io.restassured.http.ContentType;
import io.restassured.path.xml.XmlPath;
import io.restassured.response.Response;
public class CreateIncidentUsingFiles {
@DataProvider(name="Files",parallel=true)
public String[] getFileNames() {
String[] fileNames = new String[2];
fileNames[0] = "./data1.json";
fileNames[1] = "./data2.json";
return fileNames;
}
@Test(dataProvider="Files")
public void createIncident(String fileNames) {
File file = new File(fileNames);
// End Point
RestAssured.baseURI = "https://dev64481.service-now.com/api/now/v2/table/incident";
// Authorization
AuthenticationScheme basic = RestAssured.basic("admin", "7QSEbbY9Hnqb");
RestAssured.authentication = basic;
// Post the request
Response post = RestAssured
.given()
.contentType(ContentType.JSON)
.body(file)
.accept(ContentType.XML)
.post();
// response print
post.prettyPrint();
// convert to xml, field, print
XmlPath xmlPath = post.xmlPath();
String short_description = xmlPath.get("response.result.short_description");
System.out.println(short_description);
}
}