├── .gitignore
├── .idea
├── compiler.xml
├── libraries
│ ├── Maven__com_auth0_java_jwt_3_3_0.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_9_7.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_9_7.xml
│ ├── Maven__com_github_fge_btf_1_2.xml
│ ├── Maven__com_github_fge_msg_simple_1_1.xml
│ ├── Maven__com_github_fge_uri_template_0_9.xml
│ ├── Maven__com_github_java_json_tools_jackson_coreutils_1_9.xml
│ ├── Maven__com_github_java_json_tools_json_schema_core_1_2_10.xml
│ ├── Maven__com_github_java_json_tools_json_schema_validator_2_2_10.xml
│ ├── Maven__com_google_code_findbugs_jsr305_3_0_1.xml
│ ├── Maven__com_google_guava_guava_16_0_1.xml
│ ├── Maven__com_googlecode_libphonenumber_libphonenumber_8_0_0.xml
│ ├── Maven__com_sun_xml_bind_jaxb_osgi_2_2_10.xml
│ ├── Maven__com_sun_xml_bind_jaxb_osgi_2_3_0_1.xml
│ ├── Maven__commons_codec_commons_codec_1_11.xml
│ ├── Maven__commons_codec_commons_codec_1_9.xml
│ ├── Maven__commons_logging_commons_logging_1_2.xml
│ ├── Maven__info_cukes_cucumber_core_1_2_5.xml
│ ├── Maven__info_cukes_cucumber_html_0_2_3.xml
│ ├── Maven__info_cukes_cucumber_java_1_2_5.xml
│ ├── Maven__info_cukes_cucumber_jvm_deps_1_0_5.xml
│ ├── Maven__info_cukes_gherkin_2_12_2.xml
│ ├── Maven__io_rest_assured_json_path_3_3_0.xml
│ ├── Maven__io_rest_assured_json_path_4_1_2.xml
│ ├── Maven__io_rest_assured_json_schema_validator_4_1_1.xml
│ ├── Maven__io_rest_assured_json_schema_validator_4_1_2.xml
│ ├── Maven__io_rest_assured_rest_assured_3_3_0.xml
│ ├── Maven__io_rest_assured_rest_assured_4_1_2.xml
│ ├── Maven__io_rest_assured_rest_assured_common_3_3_0.xml
│ ├── Maven__io_rest_assured_rest_assured_common_4_1_2.xml
│ ├── Maven__io_rest_assured_xml_path_3_3_0.xml
│ ├── Maven__io_rest_assured_xml_path_4_1_2.xml
│ ├── Maven__javax_activation_activation_1_1_1.xml
│ ├── Maven__javax_activation_javax_activation_api_1_2_0.xml
│ ├── Maven__javax_mail_mailapi_1_4_3.xml
│ ├── Maven__javax_xml_bind_jaxb_api_2_2_12.xml
│ ├── Maven__javax_xml_bind_jaxb_api_2_3_1.xml
│ ├── Maven__joda_time_joda_time_2_9_7.xml
│ ├── Maven__net_sf_jopt_simple_jopt_simple_5_0_3.xml
│ ├── Maven__org_apache_commons_commons_lang3_3_4.xml
│ ├── Maven__org_apache_httpcomponents_httpclient_4_5_3.xml
│ ├── Maven__org_apache_httpcomponents_httpcore_4_4_6.xml
│ ├── Maven__org_apache_httpcomponents_httpmime_4_5_3.xml
│ ├── Maven__org_apache_sling_org_apache_sling_javax_activation_0_1_0.xml
│ ├── Maven__org_ccil_cowan_tagsoup_tagsoup_1_2_1.xml
│ ├── Maven__org_codehaus_groovy_groovy_2_4_15.xml
│ ├── Maven__org_codehaus_groovy_groovy_2_5_8.xml
│ ├── Maven__org_codehaus_groovy_groovy_json_2_4_15.xml
│ ├── Maven__org_codehaus_groovy_groovy_json_2_5_8.xml
│ ├── Maven__org_codehaus_groovy_groovy_xml_2_4_15.xml
│ ├── Maven__org_codehaus_groovy_groovy_xml_2_5_8.xml
│ ├── Maven__org_hamcrest_hamcrest_2_1.xml
│ ├── Maven__org_hamcrest_hamcrest_core_1_3.xml
│ ├── Maven__org_hamcrest_hamcrest_library_1_3.xml
│ ├── Maven__org_mozilla_rhino_1_7_7_1.xml
│ └── Maven__org_projectlombok_lombok_1_18_10.xml
├── misc.xml
├── modules.xml
├── uiDesigner.xml
└── workspace.xml
├── README.md
├── RestAssuredDemo.iml
├── pom.xml
├── src
├── main
│ └── java
│ │ └── utilities
│ │ ├── APIConstant.java
│ │ ├── EARestAssuredV2.java
│ │ ├── RestAssuredExtension.java
│ │ └── RestAssuredExtensionv2.java
└── test
│ └── java
│ ├── features
│ ├── ComplexDataGET.feature
│ ├── DELETEPost.feature
│ ├── GETPosts.feature
│ ├── POSTProfile.feature
│ └── PUTPost.feature
│ ├── model
│ ├── Address.java
│ ├── Location.java
│ ├── LoginBody.java
│ └── Posts.java
│ ├── pojo
│ ├── Address.java
│ ├── Location.java
│ ├── LoginBody.java
│ └── Posts.java
│ └── steps
│ ├── BDDStyledMethod.java
│ ├── GETPostsSteps.java
│ ├── POSTProfileSteps.java
│ └── TestInitialize.java
└── target
└── classes
└── post.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_auth0_java_jwt_3_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_github_fge_btf_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_github_fge_msg_simple_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_github_fge_uri_template_0_9.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_github_java_json_tools_jackson_coreutils_1_9.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_github_java_json_tools_json_schema_core_1_2_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_github_java_json_tools_json_schema_validator_2_2_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_google_guava_guava_16_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_googlecode_libphonenumber_libphonenumber_8_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_sun_xml_bind_jaxb_osgi_2_2_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_sun_xml_bind_jaxb_osgi_2_3_0_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__commons_codec_commons_codec_1_11.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__commons_codec_commons_codec_1_9.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__info_cukes_cucumber_core_1_2_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__info_cukes_cucumber_html_0_2_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__info_cukes_cucumber_java_1_2_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__info_cukes_cucumber_jvm_deps_1_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__info_cukes_gherkin_2_12_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_json_path_3_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_json_path_4_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_json_schema_validator_4_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_json_schema_validator_4_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_rest_assured_3_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_rest_assured_4_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_rest_assured_common_3_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_rest_assured_common_4_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_xml_path_3_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_rest_assured_xml_path_4_1_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__javax_activation_activation_1_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__javax_activation_javax_activation_api_1_2_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__javax_mail_mailapi_1_4_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_2_12.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__javax_xml_bind_jaxb_api_2_3_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__joda_time_joda_time_2_9_7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_5_0_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_5_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_4_6.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_httpcomponents_httpmime_4_5_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_sling_org_apache_sling_javax_activation_0_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_ccil_cowan_tagsoup_tagsoup_1_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_codehaus_groovy_groovy_2_4_15.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_codehaus_groovy_groovy_2_5_8.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_codehaus_groovy_groovy_json_2_4_15.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_codehaus_groovy_groovy_json_2_5_8.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_codehaus_groovy_groovy_xml_2_4_15.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_codehaus_groovy_groovy_xml_2_5_8.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hamcrest_hamcrest_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_mozilla_rhino_1_7_7_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_projectlombok_lombok_1_18_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
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 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 | 1538964072736
211 |
212 |
213 | 1538964072736
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 | file://$PROJECT_DIR$/src/test/java/steps/GETPostsSteps.java
222 | 115
223 |
224 |
225 |
226 | file://$PROJECT_DIR$/src/test/java/steps/GETPostsSteps.java
227 | 112
228 |
229 |
230 |
231 | file://$PROJECT_DIR$/src/test/java/steps/GETPostsSteps.java
232 | 32
233 |
234 |
235 |
236 |
237 |
238 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Rest-assured
2 | Includes complete source code of rest-assured java discussed in the youtube and udemy courses
3 |
4 | ## Course details
5 | The complete rest-assured course is available in ExecuteAutomation YouTube channel here https://www.youtube.com/playlist?list=PL6tu16kXT9PpgqfMbMdzUzDenYgb0gbk0
6 |
--------------------------------------------------------------------------------
/RestAssuredDemo.iml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | groupId
8 | RestAssuredDemo
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
13 | io.rest-assured
14 | rest-assured
15 | 3.3.0
16 |
17 |
18 |
19 |
20 | info.cukes
21 | cucumber-java
22 | 1.2.5
23 |
24 |
25 |
26 |
27 | com.fasterxml.jackson.core
28 | jackson-databind
29 | 2.9.10.8
30 |
31 |
32 |
33 |
34 | org.projectlombok
35 | lombok
36 | 1.18.10
37 | provided
38 |
39 |
40 |
41 | io.rest-assured
42 | json-schema-validator
43 | 4.1.1
44 |
45 |
46 |
47 | com.auth0
48 | java-jwt
49 | 3.3.0
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/src/main/java/utilities/APIConstant.java:
--------------------------------------------------------------------------------
1 | package utilities;
2 |
3 | public class APIConstant {
4 |
5 | public static class ApiMethods {
6 | public static String POST = "POST";
7 | public static String GET = "GET";
8 | public static String DELETE = "DELETE";
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/utilities/EARestAssuredV2.java:
--------------------------------------------------------------------------------
1 | package utilities;
2 |
3 | import com.auth0.jwt.JWT;
4 | import com.auth0.jwt.interfaces.DecodedJWT;
5 | import io.restassured.RestAssured;
6 | import io.restassured.builder.RequestSpecBuilder;
7 | import io.restassured.http.ContentType;
8 | import io.restassured.http.Header;
9 | import io.restassured.response.Response;
10 | import io.restassured.response.ResponseBody;
11 | import io.restassured.response.ResponseOptions;
12 | import io.restassured.specification.RequestSpecification;
13 | import lombok.experimental.ExtensionMethod;
14 |
15 | import java.util.Map;
16 |
17 | public class EARestAssuredV2 {
18 |
19 | private RequestSpecBuilder builder = new RequestSpecBuilder();
20 | private String method;
21 | private String url;
22 |
23 | public EARestAssuredV2(String uri, String method, String token) {
24 | //Formulate the API url
25 | this.url = "http://localhost:3000" + uri;
26 | this.method = method;
27 | //Assuming we are using only one type of token across the framework, else we need to pass token as parameter to the constructor
28 | if (token != null)
29 | builder.addHeader("Authorization", "Bearer " + token);
30 | }
31 |
32 | private ResponseOptions ExecuteAPI() {
33 |
34 | RequestSpecification requestSpec = builder.build();
35 | Response response;
36 | RequestSpecification request = RestAssured.given();
37 | request.contentType(ContentType.JSON);
38 | request.spec(requestSpec);
39 | if (this.method.equalsIgnoreCase(APIConstant.ApiMethods.POST)) {
40 | return request.post(this.url);
41 | } else if (this.method.equalsIgnoreCase(APIConstant.ApiMethods.DELETE)) {
42 | return request.delete(this.url);
43 | } else if (this.method.equalsIgnoreCase(APIConstant.ApiMethods.GET)) {
44 | return request.get(this.url);
45 | }
46 | return null;
47 | }
48 |
49 |
50 | public String Authenticate(Object body) {
51 | builder.setBody(body);
52 | return ExecuteAPI().getBody().jsonPath().get("access_token");
53 | }
54 |
55 | public ResponseOptions ExecuteWithBody(Map pathParams) {
56 | builder.addPathParams(pathParams);
57 | return ExecuteAPI();
58 | }
59 |
60 | public ResponseOptions ExecuteWithQueryParams(Map queryPath) {
61 | builder.addQueryParams(queryPath);
62 | return ExecuteAPI();
63 | }
64 |
65 | public ResponseOptions ExecuteWithPathParams(Map queryPath) {
66 | builder.addPathParams(queryPath);
67 | return ExecuteAPI();
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/utilities/RestAssuredExtension.java:
--------------------------------------------------------------------------------
1 | package utilities;
2 |
3 | import io.restassured.RestAssured;
4 | import io.restassured.builder.RequestSpecBuilder;
5 | import io.restassured.http.ContentType;
6 | import io.restassured.http.Header;
7 | import io.restassured.response.Response;
8 | import io.restassured.response.ResponseOptions;
9 | import io.restassured.specification.RequestSpecification;
10 |
11 | import java.net.URI;
12 | import java.net.URISyntaxException;
13 | import java.util.Map;
14 |
15 | public class RestAssuredExtension {
16 |
17 | public static RequestSpecification Request;
18 |
19 | public RestAssuredExtension() {
20 | //Arrange
21 | RequestSpecBuilder builder = new RequestSpecBuilder();
22 | builder.setBaseUri("http://localhost:3000/");
23 | builder.setContentType(ContentType.JSON);
24 | var requestSpec = builder.build();
25 | Request = RestAssured.given().spec(requestSpec);
26 | }
27 |
28 | public static void GetOpsWithPathParameter(String url, Map pathParams) {
29 | //Act
30 | Request.pathParams(pathParams);
31 | try {
32 | Request.get(new URI(url));
33 | } catch (URISyntaxException e) {
34 | e.printStackTrace();
35 | }
36 | }
37 |
38 | public static ResponseOptions GetOps(String url) {
39 | //Act
40 | try {
41 | return Request.get(new URI(url));
42 | } catch (URISyntaxException e) {
43 | e.printStackTrace();
44 | }
45 | return null;
46 | }
47 |
48 | public static ResponseOptions GetOpsWithToken(String url, String token) {
49 | //Act
50 | try {
51 | Request.header(new Header("Authorization", "Bearer " + token));
52 | return Request.get(new URI(url));
53 | } catch (URISyntaxException e) {
54 | e.printStackTrace();
55 | }
56 | return null;
57 | }
58 |
59 | public static ResponseOptions PUTOpsWithBodyAndPathParams(String url, Map body, Map pathParams) {
60 | Request.pathParams(pathParams);
61 | Request.body(body);
62 | return Request.put(url);
63 | }
64 | public static ResponseOptions PostOpsWithBodyAndPathParams(String url, Map pathParams, Map body) {
65 | Request.pathParams(pathParams);
66 | Request.body(body);
67 | return Request.post(url);
68 | }
69 | public static ResponseOptions DeleteOpsWithPathParams(String url,Map pathParams) {
70 | Request.pathParams(pathParams);
71 | return Request.delete(url);
72 | }
73 | public static ResponseOptions GetWithPathParams(String url,Map pathParams) {
74 | Request.pathParams(pathParams);
75 | return Request.get(url);
76 | }
77 |
78 | public static ResponseOptions GetWithQueryParamsWithToken(String url,Map pathParams, String token) {
79 | Request.header(new Header("Authorization", "Bearer " + token));
80 | Request.queryParams(pathParams);
81 | return Request.get(url);
82 | }
83 |
84 | public static ResponseOptions PostOpsWithBody(String url,Map body) {
85 | Request.body(body);
86 | return Request.post(url);
87 | }
88 |
89 |
90 |
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/utilities/RestAssuredExtensionv2.java:
--------------------------------------------------------------------------------
1 | package utilities;
2 |
3 | import io.restassured.RestAssured;
4 | import io.restassured.builder.RequestSpecBuilder;
5 | import io.restassured.http.ContentType;
6 | import io.restassured.response.Response;
7 | import io.restassured.response.ResponseOptions;
8 | import io.restassured.specification.RequestSpecification;
9 |
10 | import java.util.Map;
11 |
12 | public class RestAssuredExtensionv2 {
13 |
14 | private RequestSpecBuilder builder = new RequestSpecBuilder();
15 | private String method;
16 | private String url;
17 |
18 | /**
19 | * RestAssuredExtensionv2 constructor to pass the initial settings for the the following method
20 | * @param uri
21 | * @param method
22 | * @param token
23 | */
24 | public RestAssuredExtensionv2(String uri, String method, String token) {
25 |
26 | //Formulate the API url
27 | this.url = "http://localhost:3000" + uri;
28 | this.method = method;
29 |
30 | if(token != null)
31 | builder.addHeader("Authorization", "Bearer " + token);
32 | }
33 |
34 | /**
35 | * ExecuteAPI to execute the API for GET/POST/DELETE
36 | * @return ResponseOptions
37 | */
38 | private ResponseOptions ExecuteAPI() {
39 | RequestSpecification requestSpecification = builder.build();
40 | RequestSpecification request = RestAssured.given();
41 | request.contentType(ContentType.JSON);
42 | request.spec(requestSpecification);
43 |
44 | if(this.method.equalsIgnoreCase(APIConstant.ApiMethods.POST))
45 | return request.post(this.url);
46 | else if(this.method.equalsIgnoreCase(APIConstant.ApiMethods.DELETE))
47 | return request.delete(this.url);
48 | else if(this.method.equalsIgnoreCase(APIConstant.ApiMethods.GET))
49 | return request.get(this.url);
50 | return null;
51 | }
52 |
53 | /**
54 | * Authenticate to get the token variable
55 | * @param body
56 | * @return string token
57 | */
58 | public String Authenticate(Object body) {
59 | builder.setBody(body);
60 | return ExecuteAPI().getBody().jsonPath().get("access_token");
61 | }
62 |
63 | /**
64 | * Executing API with query params being passed as the input of it
65 | * @param queryPath
66 | * @return Reponse
67 | */
68 | public ResponseOptions ExecuteWithQueryParams(Map queryPath) {
69 | builder.addQueryParams(queryPath);
70 | return ExecuteAPI();
71 | }
72 |
73 | /**
74 | * ExecuteWithPathParams
75 | * @param pathParams
76 | * @return
77 | */
78 | public ResponseOptions ExecuteWithPathParams(Map pathParams) {
79 | builder.addPathParams(pathParams);
80 | return ExecuteAPI();
81 | }
82 |
83 | /**
84 | * ExecuteWithPathParamsAndBody
85 | * @param pathParams
86 | * @param body
87 | * @return
88 | */
89 | public ResponseOptions ExecuteWithPathParamsAndBody(Map pathParams, Map body) {
90 | builder.setBody(body);
91 | builder.addPathParams(pathParams);
92 | return ExecuteAPI();
93 | }
94 |
95 |
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/src/test/java/features/ComplexDataGET.feature:
--------------------------------------------------------------------------------
1 | Feature: ComplexDataGet
2 | Verify complex data
3 |
4 |
5 | # @smoke
6 | # Scenario: Verify GET operation for complex data
7 | # Given I perform authentication operation for "/auth/login" with body
8 | # | email | password |
9 | # | karthik@email.com | haha123 |
10 | # And I perform GET operation with path parameter for address "/address/"
11 | # | id |
12 | # | 1 |
13 | # Then I should see the street name as "1st street"
14 |
15 | @smoke
16 | Scenario: Verify GET operation for complex data
17 | Given I perform authentication operation for "/auth/login" with body
18 | | email | password |
19 | | karthik@email.com | haha123 |
20 | And I perform GET operation with path parameter for address "/location/"
21 | | id |
22 | | 1 |
23 | Then I should see the street name as "1st street"
24 |
--------------------------------------------------------------------------------
/src/test/java/features/DELETEPost.feature:
--------------------------------------------------------------------------------
1 | Feature: DeletePosts
2 | Test the delete operation
3 |
4 | @smoke
5 | Scenario: Verify DELETE operation after POST
6 | Given I ensure to Perform POST operation for "/posts" with body as
7 | | id | title | author |
8 | | 6 | API Testing course | ExecuteAutomation |
9 | And I Perform DELETE operation for "/posts/{postid}/"
10 | | postid |
11 | | 6 |
12 | And I perform GET operation with path parameter for "/posts/{postid}"
13 | | postid |
14 | | 6 |
15 | Then I "should not" see the body with title as "API Testing course"
16 |
--------------------------------------------------------------------------------
/src/test/java/features/GETPosts.feature:
--------------------------------------------------------------------------------
1 | Feature: GETPosts
2 | Verify different GET operations using REST-assured
3 |
4 | Scenario: Verify one author of the post
5 | Given I perform GET operation for "/posts"
6 | Then I should see the author name as "Karthik KK"
7 |
8 | Scenario: Verify collection of authors in the post
9 | Given I perform GET operation for "/posts"
10 | Then I should see the author names
11 |
12 | Scenario: Verify Parameter of Get
13 | Given I perform GET operation for "/posts"
14 | Then I should see verify GET Parameter
15 |
16 | @smoke
17 | Scenario: Verify GET operation with bearer authentication token
18 | Given I perform authentication operation for "/auth/login" with body
19 | | email | password |
20 | | karthik@email.com | haha123 |
21 | Given I perform GET operation for "/posts/1"
22 | Then I should see the author name as "Karthik KK"
23 |
24 | @smoke
25 | Scenario: Verify GET operation with json validation
26 | Given I perform authentication operation for "/auth/login" with body
27 | | email | password |
28 | | karthik@email.com | haha123 |
29 | Given I perform GET operation for "/posts/1"
30 | Then I should see the author name as "Karthik KK" with json validation
--------------------------------------------------------------------------------
/src/test/java/features/POSTProfile.feature:
--------------------------------------------------------------------------------
1 | Feature: PostProfile
2 | Test POST operation using REST-assured library
3 |
4 | @smoke
5 | Scenario: Verify Post operation for Profile
6 | Given I Perform POST operation for "/posts/{profileNo}/profile" with body
7 | | name | profile |
8 | | Sams | 2 |
9 | Then I should see the body has name as "Sams"
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/test/java/features/PUTPost.feature:
--------------------------------------------------------------------------------
1 | Feature: PUTPost
2 | Verify put post operation
3 |
4 | @smoke
5 | Scenario: Verify PUT operation after POST
6 | Given I ensure to Perform POST operation for "/posts" with body as
7 | | id | title | author |
8 | | 6 | API Testing course | ExecuteAutomation |
9 | And I Perform PUT operation for "/posts/{postid}/"
10 | | id | title | author |
11 | | 6 | API Testing Guide | ExecuteAutomation |
12 | And I perform GET operation with path parameter for "/posts/{postid}"
13 | | postid |
14 | | 6 |
15 | Then I "should" see the body with title as "API Testing Guide"
16 |
--------------------------------------------------------------------------------
/src/test/java/model/Address.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | import lombok.Data;
4 |
5 |
6 | //More complex
7 |
8 | @Data
9 | public class Address {
10 | private String street;
11 | private String flat_no;
12 | private int pincode;
13 | private String type;
14 | }
--------------------------------------------------------------------------------
/src/test/java/model/Location.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 |
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | import java.util.List;
8 |
9 | @Data
10 | public class Location {
11 | private int id;
12 | private String city;
13 | private String country;
14 | private List address;
15 |
16 | // @Data
17 | // public static class Address {
18 | // private String street;
19 | // private String flat_no;
20 | // private int pincode;
21 | // private String type;
22 | // }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/model/LoginBody.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | public class LoginBody {
4 | private String email;
5 | private String password;
6 |
7 | public LoginBody() {}
8 |
9 | public String getEmail() {
10 | return email;
11 | }
12 |
13 | public void setEmail(String email) {
14 | this.email = email;
15 | }
16 |
17 | public String getPassword() {
18 | return password;
19 | }
20 |
21 | public void setPassword(String password) {
22 | this.password = password;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/model/Posts.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 |
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | @Data
8 | @Builder
9 | public class Posts {
10 | private int id;
11 | private String title;
12 | private String author;
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/java/pojo/Address.java:
--------------------------------------------------------------------------------
1 | package pojo;
2 |
3 | public class Address {
4 | private String street;
5 | private String flat_no;
6 | private int pincode;
7 | private String type;
8 |
9 | Address() {}
10 |
11 | public String getStreet() {
12 | return street;
13 | }
14 |
15 | public void setStreet(String street) {
16 | this.street = street;
17 | }
18 |
19 | public String getFlat_no() {
20 | return flat_no;
21 | }
22 |
23 | public void setFlat_no(String flat_no) {
24 | this.flat_no = flat_no;
25 | }
26 |
27 | public int getPincode() {
28 | return pincode;
29 | }
30 |
31 | public void setPincode(int pincode) {
32 | this.pincode = pincode;
33 | }
34 |
35 | public String getType() {
36 | return type;
37 | }
38 |
39 | public void setType(String type) {
40 | this.type = type;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/pojo/Location.java:
--------------------------------------------------------------------------------
1 | package pojo;
2 |
3 | import java.util.List;
4 |
5 | public class Location {
6 | private int id;
7 | private String city;
8 | private String country;
9 | private List address;
10 |
11 | Location() {}
12 |
13 | public void setId(int id) {
14 | this.id = id;
15 | }
16 |
17 | public void setCity(String city) {
18 | this.city = city;
19 | }
20 |
21 | public void setCountry(String country) {
22 | this.country = country;
23 | }
24 |
25 | public void setAddress(List address) {
26 | this.address = address;
27 | }
28 |
29 | public int getId() {
30 | return id;
31 | }
32 |
33 | public String getCity() {
34 | return city;
35 | }
36 |
37 | public String getCountry() {
38 | return country;
39 | }
40 |
41 | public List getAddress() {
42 | return address;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/pojo/LoginBody.java:
--------------------------------------------------------------------------------
1 | package pojo;
2 |
3 | public class LoginBody {
4 |
5 | private String email;
6 | private String password;
7 |
8 | public LoginBody() {}
9 |
10 | public String getEmail() {
11 | return email;
12 | }
13 |
14 | public void setEmail(String email) {
15 | this.email = email;
16 | }
17 |
18 | public String getPassword() {
19 | return password;
20 | }
21 |
22 | public void setPassword(String password) {
23 | this.password = password;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/pojo/Posts.java:
--------------------------------------------------------------------------------
1 | package pojo;
2 |
3 | public class Posts {
4 | private int id;
5 | private String title;
6 | private String author;
7 |
8 | Posts() {}
9 |
10 | public Posts(int id, String title, String author) {
11 | this.id = id;
12 | this.title = title;
13 | this.author = author;
14 | }
15 |
16 | public void setId(int id) {
17 | this.id = id;
18 | }
19 |
20 | public void setTitle(String title) {
21 | this.title = title;
22 | }
23 |
24 | public void setAuthor(String author) {
25 | this.author = author;
26 | }
27 |
28 | public int getId() {
29 | return id;
30 | }
31 |
32 | public String getTitle() {
33 | return title;
34 | }
35 |
36 | public String getAuthor() {
37 | return author;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/steps/BDDStyledMethod.java:
--------------------------------------------------------------------------------
1 | package steps;
2 |
3 | import io.restassured.http.ContentType;
4 | import org.hamcrest.core.Is;
5 |
6 | import java.util.HashMap;
7 |
8 | import static io.restassured.RestAssured.given;
9 | import static io.restassured.RestAssured.when;
10 | import static org.hamcrest.CoreMatchers.containsString;
11 | import static org.hamcrest.CoreMatchers.hasItem;
12 | import static org.hamcrest.CoreMatchers.is;
13 | import static org.hamcrest.Matchers.containsInAnyOrder;
14 |
15 | public class BDDStyledMethod {
16 |
17 |
18 | public static void SimpleGETPost(String postNumber){
19 | given().contentType(ContentType.JSON).
20 | when().get(String.format("http://localhost:3000/posts/%s", postNumber)).
21 | then().body("author", is("Karthik KK"));
22 | }
23 |
24 | public static void PerformContainsCollection() {
25 | given()
26 | .contentType(ContentType.JSON)
27 | .when()
28 | .get("http://localhost:3000/posts/")
29 | .then()
30 | .body("author", containsInAnyOrder("Karthik KK", "Karthik KK", null)).statusCode(204);
31 | }
32 |
33 | public static void PerformPathParameter() {
34 |
35 | given()
36 | .contentType(ContentType.JSON).
37 | with()
38 | .pathParams("post", 1).
39 | when()
40 | .get("http://localhost:3000/posts/{post}").
41 | then()
42 | .body("author", containsString("Karthik KK"));
43 | }
44 |
45 | public static void PerformQueryParameter(){
46 | given()
47 | .contentType(ContentType.JSON)
48 | .queryParam("id", 1).
49 | when()
50 | .get("http://localhost:3000/posts/").
51 | then()
52 | .body("author", hasItem("Karthik KK"));
53 | }
54 |
55 | public static void PerformPOSTWithBodyParameter() {
56 | HashMap postContent = new HashMap<>();
57 | postContent.put("id", "5");
58 | postContent.put("title", "Robotium course");
59 | postContent.put("author", "ExecuteAutomation");
60 |
61 | given()
62 | .contentType(ContentType.JSON).
63 | with()
64 | .body(postContent).
65 | when()
66 | .post("http://localhost:3000/posts").
67 | then()
68 | .body("author", Is.is("ExecuteAutomation"));
69 | }
70 |
71 |
72 |
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/test/java/steps/GETPostsSteps.java:
--------------------------------------------------------------------------------
1 | package steps;
2 |
3 | import cucumber.api.DataTable;
4 | import cucumber.api.java.en.And;
5 | import cucumber.api.java.en.Given;
6 | import cucumber.api.java.en.Then;
7 | import io.restassured.response.Response;
8 | import io.restassured.response.ResponseOptions;
9 | import model.Address;
10 | import model.Location;
11 | import model.LoginBody;
12 | import model.Posts;
13 | import utilities.APIConstant;
14 | import utilities.EARestAssuredV2;
15 | import utilities.RestAssuredExtension;
16 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
17 |
18 | import java.util.HashMap;
19 | import java.util.Map;
20 |
21 | import static org.hamcrest.CoreMatchers.equalTo;
22 | import static org.hamcrest.CoreMatchers.hasItem;
23 | import static org.hamcrest.MatcherAssert.assertThat;
24 |
25 | public class GETPostsSteps {
26 |
27 |
28 | public static ResponseOptions response;
29 | public static String token;
30 |
31 | @Given("^I perform GET operation for \"([^\"]*)\"$")
32 | public void iPerformGETOperationFor(String url) throws Throwable {
33 | response = RestAssuredExtension.GetOpsWithToken(url, token);
34 | }
35 |
36 | @And("^I perform GET operation with path parameter for address \"([^\"]*)\"$")
37 | public void iPerformGETOperationWithPathParameterForAddress(String url, DataTable table) throws Throwable {
38 | var data = table.raw();
39 |
40 | Map queryParams = new HashMap<>();
41 | queryParams.put("id", data.get(1).get(0));
42 |
43 | //response = RestAssuredExtension.GetWithQueryParamsWithToken(url, pathParams, response.getBody().jsonPath().get("access_token"));
44 |
45 | EARestAssuredV2 eaRestAssuredV2 = new EARestAssuredV2(url,APIConstant.ApiMethods.GET,token);
46 | response = eaRestAssuredV2.ExecuteWithQueryParams(queryParams);
47 | }
48 |
49 | @Then("^I should see the author name as \"([^\"]*)\"$")
50 | public void iShouldSeeTheAuthorNameAs(String authorName) throws Throwable {
51 |
52 | var posts = new Posts.Builder().build();
53 |
54 | var post = response.getBody().as(posts.getClass());
55 |
56 | assertThat(post.getAuthor(), equalTo("Karthik KK"));
57 |
58 | //assertThat(posts[0].getAuthor(), equalTo("Karthik KK"));
59 | }
60 |
61 | //Deserialize
62 |
63 | @Then("^I should see the author name as \"([^\"]*)\" with json validation$")
64 | public void iShouldSeeTheAuthorNameAsWithJsonValidation(String authorName) throws Throwable {
65 |
66 | var a = response.getBody().asString();
67 |
68 | assertThat(a, matchesJsonSchemaInClasspath("post.json"));
69 |
70 |
71 |
72 | // assertThat(response.getBody().jsonPath().get("author"), hasItem("Karthik KK"));
73 | }
74 |
75 | @Then("^I should see the author names$")
76 | public void iShouldSeeTheAuthorNames() throws Throwable {
77 | BDDStyledMethod.PerformContainsCollection();
78 | }
79 |
80 | @Then("^I should see verify GET Parameter$")
81 | public void iShouldSeeVerifyGETParameter() throws Throwable {
82 | BDDStyledMethod.PerformPathParameter();
83 | }
84 |
85 |
86 | @Given("^I perform authentication operation for \"([^\"]*)\" with body$")
87 | public void iPerformAuthenticationOperationForWithBody(String url, DataTable table) throws Throwable {
88 |
89 | var data = table.raw();
90 |
91 | // HashMap body = new HashMap<>();
92 | // body.put("email", data.get(1).get(0));
93 | // body.put("password", data.get(1).get(1));
94 |
95 | LoginBody loginBody = new LoginBody();
96 | loginBody.setEmail(data.get(1).get(0));
97 | loginBody.setPassword(data.get(1).get(1));
98 |
99 | EARestAssuredV2 eaRestAssuredV2 = new EARestAssuredV2(url, APIConstant.ApiMethods.POST, token);
100 |
101 | //token = eaRestAssuredV2.Authenticate(body);
102 |
103 | token = eaRestAssuredV2.Authenticate(loginBody);
104 | }
105 |
106 | @Then("^I should see the street name as \"([^\"]*)\"$")
107 | public void iShouldSeeTheStreetNameAs(String streetName) throws Throwable {
108 |
109 | var a = response.getBody().as(Location[].class);
110 |
111 | Address address = a[0].getAddress().stream().filter(x -> x.getType().equalsIgnoreCase("primary")).findFirst().orElse(null);
112 |
113 | assertThat(address.getStreet(), equalTo(streetName));
114 |
115 |
116 | // assertThat(a[0].getAddress().getStreet(), equalTo(streetName));
117 |
118 |
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/test/java/steps/POSTProfileSteps.java:
--------------------------------------------------------------------------------
1 | package steps;
2 |
3 | import cucumber.api.DataTable;
4 | import cucumber.api.PendingException;
5 | import cucumber.api.java.en.And;
6 | import cucumber.api.java.en.Given;
7 | import cucumber.api.java.en.Then;
8 | import io.restassured.response.Response;
9 | import io.restassured.response.ResponseBody;
10 | import io.restassured.response.ResponseOptions;
11 | import lombok.experimental.ExtensionMethod;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.hamcrest.core.IsNot;
14 | import utilities.EARestAssuredV2;
15 | import utilities.RestAssuredExtension;
16 |
17 | import javax.xml.crypto.Data;
18 | import java.util.HashMap;
19 | import java.util.Map;
20 |
21 | import static org.hamcrest.CoreMatchers.equalTo;
22 | import static org.hamcrest.CoreMatchers.is;
23 | import static org.hamcrest.MatcherAssert.assertThat;
24 |
25 | public class POSTProfileSteps {
26 |
27 | public static ResponseOptions response;
28 |
29 | @Given("^I Perform POST operation for \"([^\"]*)\" with body$")
30 | public void iPerformPOSTOperationForWithBody(String url, DataTable table) throws Throwable {
31 |
32 | var data = table.raw();
33 |
34 | //Set body
35 | HashMap body = new HashMap<>();
36 | body.put("name", data.get(1).get(0));
37 |
38 | //Path params
39 | HashMap pathParams = new HashMap<>();
40 | pathParams.put("profileNo", data.get(1).get(1));
41 |
42 | //Perform post operation
43 | response = RestAssuredExtension.PostOpsWithBodyAndPathParams(url, pathParams, body);
44 | }
45 |
46 | @Then("^I should see the body has name as \"([^\"]*)\"$")
47 | public void iShouldSeeTheBodyHasNameAs(String name) throws Throwable {
48 | assertThat(response.getBody().jsonPath().get("name"), equalTo(name));
49 | }
50 |
51 |
52 | @Given("^I ensure to Perform POST operation for \"([^\"]*)\" with body as$")
53 | public void iEnsureToPerformPOSTOperationForWithBodyAs(String url, DataTable table) throws Throwable {
54 | var data = table.raw();
55 |
56 | Map body = new HashMap<>();
57 | body.put("id", data.get(1).get(0));
58 | body.put("title", data.get(1).get(1));
59 | body.put("author", data.get(1).get(2));
60 |
61 | //Perform post operation
62 | RestAssuredExtension.PostOpsWithBody(url, body);
63 | }
64 |
65 | @And("^I Perform DELETE operation for \"([^\"]*)\"$")
66 | public void iPerformDELETEOperationFor(String url, DataTable table) throws Throwable {
67 | var data = table.raw();
68 |
69 | Map pathParams = new HashMap<>();
70 | pathParams.put("postid", data.get(1).get(0));
71 |
72 | //Perform Delete operation
73 | RestAssuredExtension.DeleteOpsWithPathParams(url, pathParams);
74 | }
75 |
76 | @Then("^I \"([^\"]*)\" see the body with title as \"([^\"]*)\"$")
77 | public void iShouldNotSeeTheBodyWithTitleAs(String condition, String title) throws Throwable {
78 |
79 | if (condition.equalsIgnoreCase("should not"))
80 | assertThat(response.getBody().jsonPath().get("title"), IsNot.not(title));
81 | else
82 | assertThat(response.getBody().jsonPath().get("title"), is(title));
83 | }
84 |
85 | @And("^I perform GET operation with path parameter for \"([^\"]*)\"$")
86 | public void iPerformGETOperationWithPathParameterFor(String url, DataTable table) throws Throwable {
87 | var data = table.raw();
88 |
89 | Map pathParams = new HashMap<>();
90 | pathParams.put("postid", data.get(1).get(0));
91 |
92 | response = RestAssuredExtension.GetWithPathParams(url, pathParams);
93 | }
94 |
95 |
96 |
97 | @And("^I Perform PUT operation for \"([^\"]*)\"$")
98 | public void iPerformPUTOperationFor(String url, DataTable table) throws Throwable {
99 | var data = table.raw();
100 |
101 | Map body = new HashMap<>();
102 | body.put("id", data.get(1).get(0));
103 | body.put("title", data.get(1).get(1));
104 | body.put("author", data.get(1).get(2));
105 |
106 | Map pathParams = new HashMap<>();
107 | pathParams.put("postid", data.get(1).get(0));
108 |
109 | //Perform post operation
110 | RestAssuredExtension.PUTOpsWithBodyAndPathParams(url, body, pathParams);
111 |
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/src/test/java/steps/TestInitialize.java:
--------------------------------------------------------------------------------
1 | package steps;
2 |
3 | import cucumber.api.java.Before;
4 | import lombok.extern.slf4j.Slf4j;
5 | import utilities.RestAssuredExtension;
6 |
7 | public class TestInitialize {
8 |
9 | @Before
10 | public void TestSetup(){
11 | RestAssuredExtension restAssuredExtension = new RestAssuredExtension();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/target/classes/post.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "1",
3 | "title": "json-server",
4 | "author": "Karthik KK"
5 | }
--------------------------------------------------------------------------------