-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change type to var #6
base: master
Are you sure you want to change the base?
Changes from 9 commits
bc0b98d
eb3934e
e85219c
82964a0
410e80c
11190ad
f02720e
54cd243
db6ae4a
ca7a5f9
ebe2311
832d1ed
a6363ec
f6701fe
844c366
3588390
04fcb79
6810e52
28c9a88
9be2a4e
f35bbeb
79f2e79
4d84e10
6eb407c
04ee4c9
362ce7d
fa23796
446951c
4050880
d02ffb4
4c1865d
3dde365
bbaf053
4a07108
e6c496d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
/** | ||
* | ||
*/ | ||
package posters.cucumber.support; | ||
|
||
import java.util.ArrayList; | ||
|
@@ -38,8 +35,15 @@ public Product addProduct(Product product) | |
// increase amount of product if already there or add the whole product | ||
if (products.contains(product)) | ||
{ | ||
Product updatedProduct = products.get(products.indexOf(product)); | ||
updatedProduct.setAmount(updatedProduct.getAmount() + 1); | ||
var updatedProduct = products.get(products.indexOf(product)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oomelianchuk Please reuse updateCountOfProduct if possible. We should not implement the same functions again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
String name = updatedProduct.getName(); | ||
String unitPrice = updatedProduct.getUnitPrice(); | ||
String style = updatedProduct.getStyle(); | ||
String size = updatedProduct.getSize(); | ||
int amount = updatedProduct.getAmount(); | ||
products.remove(updatedProduct); | ||
updatedProduct = new Product(name, unitPrice, style, size, amount + 1); | ||
products.add(updatedProduct); | ||
return updatedProduct; | ||
} | ||
else | ||
|
@@ -48,16 +52,33 @@ public Product addProduct(Product product) | |
return product; | ||
} | ||
} | ||
|
||
public void removeProduct(String productName, String style, String size) | ||
public Product getProductFromArrayList(String name, String size, String style) | ||
{ | ||
int i = 0; | ||
for (Product product : products) | ||
{ | ||
if (product.getName().equals(productName) && product.getSize().equals(size) | ||
if (product.getName().equals(name) && product.getSize().equals(size) | ||
&& product.getStyle().equals(style)) | ||
{ | ||
products.remove(product); | ||
i = products.indexOf(product); | ||
} | ||
} | ||
return products.get(i); | ||
} | ||
|
||
public void updateCountOfProduct(String name, String size, String style, int amount) | ||
{ | ||
var updateProducht = getProductFromArrayList(name, size, style); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
String unitPrice = updateProducht.getUnitPrice(); | ||
products.remove(products.indexOf(updateProducht)); | ||
updateProducht = new Product(name, unitPrice, style, size, amount); | ||
products.add(updateProducht); | ||
} | ||
|
||
public void removeProduct(String name, String style, String size) | ||
{ | ||
var updateProducht = getProductFromArrayList(name, size, style); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
products.remove(products.indexOf(updateProducht)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,58 +8,53 @@ | |
import io.cucumber.java.en.Given; | ||
import io.qameta.allure.Step; | ||
import posters.pageobjects.pages.browsing.HomePage; | ||
import posters.pageobjects.pages.browsing.ProductdetailPage; | ||
import posters.pageobjects.pages.browsing.ProductDetailPage; | ||
import posters.pageobjects.pages.user.LoginPage; | ||
import posters.pageobjects.pages.user.RegisterPage; | ||
|
||
public class OpenPageFlows | ||
{ | ||
@Given("^homepage is loaded$") | ||
@Step("open home page") | ||
public static HomePage homepage() | ||
public static HomePage homePage() | ||
{ | ||
// clear cookies to ensure a new session | ||
clearBrowserCookies(); | ||
// open home page | ||
open(Neodymium.configuration().url()); | ||
HomePage homePage = new HomePage(); | ||
homePage.isExpectedPage(); | ||
return homePage; | ||
return new HomePage().isExpectedPage(); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oomelianchuk Please remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
@Given("^login page is loaded$") | ||
@Step("open login page") | ||
public static LoginPage loginPage() | ||
{ | ||
// open login page and check for expected page | ||
LoginPage loginPage = homepage().userMenu.openLogin(); | ||
loginPage.isExpectedPage(); | ||
return loginPage; | ||
return homePage().userMenu.openLogin(); | ||
}; | ||
|
||
@Given("^register page is loaded$") | ||
@Step("open register page") | ||
public static RegisterPage registerPage() | ||
{ | ||
// open login page and check for expected page | ||
RegisterPage registerPage = homepage().userMenu.openRegister(); | ||
registerPage.isExpectedPage(); | ||
return registerPage; | ||
return homePage().userMenu.openRegister(); | ||
}; | ||
|
||
@Given("^product page \"([^\"]*)\" is open$") | ||
@Step("open product page with cleared cookes") | ||
public static ProductdetailPage openProductdetailsPageWithClearedCookes(String url) | ||
public static ProductDetailPage openProductdetailsPageWithClearedCookes(String url) | ||
{ | ||
clearBrowserCookies(); | ||
open(Neodymium.configuration().url() + url); | ||
return new ProductdetailPage(); | ||
return new ProductDetailPage(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please call isExpectedPage() to validate the result There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
|
||
// TODO check if needed - else delete | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oomelianchuk Please take care of the TODO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method is called in |
||
@Step("open product page without cleared cookes") | ||
public static ProductdetailPage openProductdetailsPage(String url) | ||
public static ProductDetailPage openProductdetailsPage(String url) | ||
{ | ||
open(Neodymium.configuration().url() + url); | ||
return new ProductdetailPage(); | ||
return new ProductDetailPage(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please call isExpectedPage() to validate the result There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,15 +9,9 @@ | |
import posters.dataobjects.Product; | ||
import posters.dataobjects.User; | ||
import posters.pageobjects.pages.browsing.HomePage; | ||
import posters.pageobjects.pages.browsing.ProductdetailPage; | ||
import posters.pageobjects.pages.checkout.CartPage; | ||
import posters.pageobjects.pages.browsing.ProductDetailPage; | ||
import posters.pageobjects.pages.checkout.PaymentPage; | ||
import posters.pageobjects.pages.checkout.PlaceOrderPage; | ||
import posters.pageobjects.pages.checkout.ShippingAddressPage; | ||
import posters.pageobjects.pages.user.AccountOverviewPage; | ||
import posters.pageobjects.pages.user.LoginPage; | ||
import posters.pageobjects.pages.user.OrderHistoryPage; | ||
import posters.pageobjects.pages.user.RegisterPage; | ||
import posters.pageobjects.utility.PriceHelper; | ||
|
||
public class OrderSupport | ||
|
@@ -33,97 +27,93 @@ public OrderSupport(GlobalStorage storage) | |
@Given("^new user with \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\" is registered and logged in$") | ||
public void registerAndLogIn(String firstName, String lastName, String email, String password) | ||
{ | ||
RegisterPage registerPage = OpenPageFlows.registerPage(); | ||
var registerPage = OpenPageFlows.registerPage(); | ||
registerPage.isExpectedPage(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check all "Support" classes. We should have added the |
||
storage.user = new User(firstName, lastName, email, password); | ||
registerPage.sendRegisterForm(firstName, lastName, email, password, password); | ||
LoginPage loginPage = registerPage.userMenu.openLogin(); | ||
loginPage.isExpectedPage(); | ||
var loginPage = registerPage.userMenu.openLogin();; | ||
loginPage.sendLoginform(email, password); | ||
} | ||
|
||
@Then("^all the products are to find in order history$") | ||
public void validateOrderInOrderHistory() | ||
@When("I add this product with size \"([^\"]*)\" and style \"([^\"]*)\" to the cart$") | ||
public void addProductToCart(String size, String style) | ||
{ | ||
AccountOverviewPage accountOverview = new HomePage().userMenu.openAccountOverview(); | ||
accountOverview.isExpectedPage(); | ||
OrderHistoryPage orderHistory = accountOverview.openOrderHistory(); | ||
for (Product product : storage.products) | ||
{ | ||
orderHistory.validateContainsProduct(product); | ||
} | ||
} | ||
var productDetailPage = new ProductDetailPage(); | ||
productDetailPage.setSize(size); | ||
productDetailPage.setStyle(style); | ||
|
||
var product = storage.addProduct(productDetailPage.getProduct()); | ||
|
||
productDetailPage.addToCart(); | ||
productDetailPage.miniCart.openMiniCart(); | ||
productDetailPage.miniCart.validateMiniCartByProduct(product); | ||
} | ||
|
||
@When("^I add product \"([^\"]*)\" in size \"([^\"]*)\" and style \"([^\"]*)\"$") | ||
@Step("open product page and add product to the cart") | ||
public void openProductPageAndAddItoTheCart(String productUrl, String size, String style) | ||
{ | ||
OpenPageFlows.openProductdetailsPage(productUrl); | ||
addProductToCart(size, style); | ||
} | ||
|
||
@When("I add this product with size \"([^\"]*)\" and style \"([^\"]*)\" to the cart$") | ||
public void addProductToCart(String size, String style) | ||
{ | ||
ProductdetailPage productPage = new ProductdetailPage(); | ||
productPage.setSize(size); | ||
productPage.setStyle(style); | ||
|
||
Product product = storage.addProduct(productPage.getProduct()); | ||
|
||
productPage.addToCart(); | ||
productPage.miniCart.openMiniCart(); | ||
productPage.miniCart.validateMiniCartByProduct(product); | ||
} | ||
|
||
|
||
@When("^I specify the shipping address \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\" and use it for billing$") | ||
public void openFillAndSendShippingFormUseForBilling(String name, String company, String address, String city, String state, String zip, String country) | ||
public void openFillAndSendShippingFormUseForBilling(String name, String company, String street, String city, String state, String zip, String country) | ||
{ | ||
CartPage cartPage = new ProductdetailPage().miniCart.openCartPage(); | ||
cartPage.isExpectedPage(); | ||
ShippingAddressPage shippingPage = cartPage.openShippingPage(); | ||
shippingPage.isExpectedPage(); | ||
shippingPage.sendShippingAddressForm(name, company, address, city, state, zip, country, true); | ||
storage.shippingAddress = new Address(name, company, address, city, state, zip, country); | ||
storage.billingAddress = new Address(name, company, address, city, state, zip, country); | ||
var cartPage = new ProductDetailPage().miniCart.openCartPage(); | ||
var shippingAddressPage = cartPage.openShippingPage(); | ||
shippingAddressPage.sendShippingAddressForm(name, company, street, city, state, zip, country, true); | ||
|
||
storage.shippingAddress = new Address(storage.user.getFirstName(), storage.user.getLastName(), company, street, city, state, zip, country); | ||
storage.billingAddress = new Address(storage.user.getFirstName(), storage.user.getLastName(), company, street, city, state, zip, country); | ||
new PaymentPage().isExpectedPage(); | ||
} | ||
|
||
@When("^I enter payment data \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\"$") | ||
public void fillAndSendPaymentForm(String name, String cardNumber, String month, String year) | ||
{ | ||
PaymentPage paymentPage = new PaymentPage(); | ||
var paymentPage = new PaymentPage(); | ||
paymentPage.isExpectedPage(); | ||
PlaceOrderPage placeOrder = paymentPage.sendPaymentForm(cardNumber, name, month, year); | ||
paymentPage.sendPaymentForm(cardNumber, name, month, year); | ||
|
||
storage.creditcard = new CreditCard(name, cardNumber, "xxxx xxxx xxxx " + cardNumber.substring(12, 16), month, year); | ||
placeOrder.isExpectedPage(); | ||
} | ||
|
||
@Then("^I see all the products in order overview$") | ||
public void validateContainsAllProductsWithCorrectPricesAndAmount() | ||
{ | ||
double subtotal = 0.0; | ||
PlaceOrderPage placeOrder = new PlaceOrderPage(); | ||
var placeOrderPage = new PlaceOrderPage(); | ||
for (Product product : storage.products) | ||
{ | ||
placeOrder.validateContainsProduct(product); | ||
placeOrderPage.validateContainsProduct(product); | ||
subtotal += product.getTotalPrice(); | ||
} | ||
placeOrder.validateSubtotal(PriceHelper.format(subtotal)); | ||
placeOrderPage.validateSubtotal(PriceHelper.format(subtotal)); | ||
} | ||
|
||
@Then("^my shipping and billing addresses as well as payment data are displayed correctly") | ||
public void validateAddressesAndPaymentData() | ||
{ | ||
PlaceOrderPage placeOrder = new PlaceOrderPage(); | ||
placeOrder.validateAddressesAndPayment(storage.shippingAddress, storage.billingAddress, storage.creditcard); | ||
var placeOrderPage = new PlaceOrderPage(); | ||
placeOrderPage.validateAddressesAndPayment(storage.shippingAddress, storage.billingAddress, storage.creditcard); | ||
} | ||
|
||
@Then("^my order is successfully placed$") | ||
public void placeOrder() | ||
{ | ||
HomePage succssefulOrder = new PlaceOrderPage().placeOrder(); | ||
succssefulOrder.isExpectedPage(); | ||
succssefulOrder.validateSuccessfulOrder(); | ||
} | ||
|
||
@Then("^all the products are to find in order history$") | ||
public void validateOrderInOrderHistory() | ||
{ | ||
var accountOverviewPage = new HomePage().userMenu.openAccountOverview(); | ||
var orderHistoryPage = accountOverviewPage.openOrderHistory(); | ||
for (Product product : storage.products) | ||
{ | ||
orderHistoryPage.validateContainsProduct(product); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oomelianchuk I think we can use
storage.updateCountOfProduct()
to shorten the code at this place.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, done