Last active
July 30, 2016 22:55
-
-
Save kkashyap1707/5c869a77e3efb530baf371c9dc38f27a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.testingalert; | |
import com.Input.InputLogin; | |
import com.jayway.restassured.RestAssured; | |
import com.jayway.restassured.response.Response; | |
import java.util.Map; | |
import java.util.concurrent.TimeUnit; | |
public class LoginRest | |
{ | |
public static void main(String args[]) | |
{ | |
InputLogin login = new InputLogin(); | |
//Set JSON Input Parameters | |
login.setApiVersion("1.0"); | |
login.setActionName("login"); | |
login.setEmail("[email protected]"); | |
login.setPassword("123456"); | |
login.setMedium("MANUAL"); | |
login.setAppKey("myAppKey"); | |
Gson gson = new Gson(); | |
gson.toJson(login); | |
System.out.println("Input JSON Request :: "+ gson.toJson(login)); //Return Input JSON Request | |
Response res = RestAssured.given().contentType("application/json").body(login).when().post("http://game.com/api/v11_2"); | |
System.out.println(" Output Response :: "+res.andReturn().asString()); //Return Output JSON Response | |
//Test Step Validation | |
try | |
{ | |
if(res.path("message").equals("Login successfully")) | |
{ | |
System.out.println("Response Time ->"+res.time()+"::::::"+ res.path("message")); | |
} | |
else | |
{ | |
System.out.println("Failure Message :: " +res.path("message")); | |
} | |
} | |
catch(Exception e) | |
{ | |
System.out.println( e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment