Skip to content

Commit

Permalink
updated date format in booking data builder
Browse files Browse the repository at this point in the history
  • Loading branch information
mfaisalkhatri committed Sep 17, 2024
1 parent 3d37eec commit 7512d25
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<playwright-version>1.45.1</playwright-version>
<playwright-version>1.47.0</playwright-version>
<testng-version>7.10.2</testng-version>
<hamcrest-all-version>1.3</hamcrest-all-version>
<json-simple-version>1.1.1</json-simple-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public final class BookingDataBuilder {
private static final Faker FAKER = new Faker();

public static BookingData getBookingData() {
final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return BookingData.builder()
.firstname(FAKER.name()
.firstName())
Expand All @@ -24,11 +23,10 @@ public static BookingData getBookingData() {
.numberBetween(1, 2000))
.depositpaid(true)
.bookingdates(BookingDates.builder()
.checkin(formatter.format(FAKER.date()
.past(20, TimeUnit.DAYS)))
.checkout(formatter.format(FAKER.date()
.future(5, TimeUnit.DAYS)))
.build())
.checkin(FAKER.timeAndDate()
.past(20, TimeUnit.DAYS,"yyyy-MM-dd"))
.checkout(FAKER.timeAndDate()
.future(5, TimeUnit.DAYS, "yyyy-MM-dd")).build())
.additionalneeds("Breakfast")
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.github.mfaisalkhatri.api.restfulecommerce;


import org.testng.annotations.Test;

public class APITests extends BaseTest{

@Test
public void testShouldCreateNewOrders() {
//request.post("/addOrder").body()
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package io.github.mfaisalkhatri.api.restfulecommerce;

import com.microsoft.playwright.APIRequest;
import com.microsoft.playwright.APIRequestContext;
import com.microsoft.playwright.Playwright;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import java.util.HashMap;
import java.util.Map;

public class BaseTest {

protected Playwright playwright;
protected APIRequestContext request;
private static final String BASE_URL = "http://localhost:3004";

@BeforeClass
public void setup() {
createPlaywright();
createAPIRequestContext();
}

@AfterClass
public void tearDown() {
disposeAPIRequestContext();
closePlaywright();

}

private void createPlaywright() {
playwright = Playwright.create();
}

private void createAPIRequestContext() {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");

request = playwright.request().newContext(new APIRequest.NewContextOptions()
.setBaseURL(BASE_URL)
.setExtraHTTPHeaders(headers));
}


private void closePlaywright() {
if (playwright != null) {
playwright.close();
playwright = null;
}
}

private void disposeAPIRequestContext() {
if (request != null) {
request.dispose();
request = null;
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.github.mfaisalkhatri.api.restfulecommerce.testdata;


import com.google.gson.annotations.SerializedName;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class OrderData {
@SerializedName("user_id")
private String userId;
@SerializedName("product_id")
private String productId;
@SerializedName("product_name")
private String productName;
@SerializedName("product_amount")
private int productAmount;
private int qty;
@SerializedName("tax_amt")
private int taxAmt;
@SerializedName("total_amt")
private int totalAmt;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.mfaisalkhatri.api.restfulecommerce.testdata;

public class OrderDataBuilder {


}

0 comments on commit 7512d25

Please sign in to comment.