Posts

Showing posts from September, 2024

Http : post- Body with Text,JavaScript,XML,HTML,Multipart,PDF

 HTTP -post- Body with Text,JavaScript,XML,HTML,Multipart,PDF public class postwithDifferentData { @Test public void bodywithsimpleText() { RestAssured.baseURI = "http://httpbin.org"; String BodyText = "Hello world API!!!"; given().log().all() .contentType(ContentType.TEXT) . body(BodyText) .when().log().all(). post("/post") .then().log().all() .assertThat().statusCode(200).body("data", equalTo("Hello world API!!!")); } Body with Java Script: public void bodywithsimpleJavaScript() { RestAssured.baseURI = "http://httpbin.org"; String JavaScript = "<script>\r\n" + "var x, y, z; \r\n" + "x = 5;    \r\n" + "y = 6;    \r\n" + "z = x + y;  \r\n" + "document.getElementById(\"demo\").innerHTML =\r\n" + "\"The value of z is \" + z + \".\";\r\n" +...

Passing Query Parameters in RestAssuredd

Image
 3 Ways to pass Query Parameter: Way 1: .queryParam("name", "Trivedi").queryParam("status", "active"). @Test public void apiGetParm() { given().log().all() .header("Authorization", "Bearer cdf88f0e405447388b7a1a71061f130bccd5f70990e848d560bafadc196b7680") .queryParam("name", "Trivedi").queryParam("status", "active"). when().log().all().get("/public/v2/users").then().log().all().assertThat().statusCode(200) .contentType(ContentType.JSON); Way 2 using dataprovider and HashMap & Put @DataProvider public Object[][] getapiData() { return new Object[][] { { "Trivedi", "active", "male" }, }; } @Test(dataProvider = "getapiData") public void queryParamsHashmap(String name, String status, String gender) { Map<String, String> queryParms = new HashMap<String, String>(); queryParms.put(...

Azure

 Service Bus Explorere: Azure Services: Azure Service Bus is like a message delivery service for your apps. Imagine you have different parts of a system (like a website, a payment service, and a shipping service), and they need to talk to each other. Instead of connecting them directly, which can get messy, Azure Service Bus acts as a middleman. Service bus :  we see the queues and the deadlocks for services 1-Create a namespace for qa,dev,stage,preprod and prod 2- we will have the queues .. for our project we have queue like Application flow with be create proposal: place an proposal order with duration , agency,advertiser,market,zones,price. order_createpropsl, order_createLinord order_createdigord order_createorder order_publshorder Order_validateorder Order_validaAgency Order_validaAdvertiser Order_submitOrder EAS- 1time-OSP- response back to EAS Function App- used to start/stop the feature flags in the project. Turn off and turn on. Proposal creation with only linear /dig...

Serialization

Image
Converting pojo to Json is Serialization:

LomBok and annotations

 package lombokeg; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /*  * Lombok is a 3rd party library , add it in pom.xml and download the jar and install in workspace eclipse location  * it auto give the setters,getters,cnstructors with augs and no args- using the annotations like below   *   *   */ @Data @Builder @AllArgsConstructor @NoArgsConstructor public class User { private String email; private String username; private String password; private String phone; private Name name; private Address addres; @Data @Builder @AllArgsConstructor @NoArgsConstructor public static class Name { private String firstname; private String lastname; } @Data @Builder @AllArgsConstructor @NoArgsConstructor public static class Address { private String city; private String street; private int number; private String zipcode; private Gealocation...

Pojo to Json - Serialization

 //jackson-databind library - it will convert pojo into json - serialization 1-Create a Pojo: 2-in Test class, create an object of the pojo class,call the pojo class and pass the constructor parameters 3.in Body(call the Object ) package UpdateUSer;- public class ecampusconnectNewCoursePojo { private String courseName; private int courseDuration; private String courseType; public ecampusconnectNewCoursePojo(String courseName, int courseDuration, String courseType) { this.courseName = courseName; this.courseDuration = courseDuration; this.courseType = courseType; } public String getCourseName() { return courseName; } public void setCourseName(String courseName) { this.courseName = courseName; } public int getCourseDuration() { return courseDuration; } public void setCourseDuration(int courseDuration) { this.courseDuration = courseDuration; } public String getCourseType() { return courseType; } public void setCourseType(Stri...

RestAssured API Framework

Rest Assured-- core features --jdk gives httpclient, so we can call using httpclient wrappers libraies aviable on top of httpclient ---Rest assured OKHttpClient JerseyClient ----------------------------------- Request  -Method - get,put,post,delete -URL - baseURL + /endpoint + query params -HEADER : -Request Body/PayLoad -Auth :Oauth1 , Oauth2, JWT, BearerToken,APIKEY,Basic Auth Response - status -status line - body: jsonpath,xmlpath() -Headers -Cookies open suce java dsl MAVEN -maven-archetype-quick -restAssured LIB :pom.xml TESTNG: unit test framework ** api runs in sequal mode no parral like UI *************************** BDD Style - approach/methodology  given, when , then  NON -BDD Approach RestAssured--is builder patterm and method chaining given().log().all().then().get().when().assertThat().statuscode(200); Hamcrest Library->RestAssured have Matchers library  https://documenter.getpostman.com/view/4012288/TzK2bEa8#intro 08608080288 immutable map it means i...