-
Notifications
You must be signed in to change notification settings - Fork 3
Change type to var #6
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
base: master
Are you sure you want to change the base?
Changes from 22 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,9 +35,8 @@ 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); | ||
| return updatedProduct; | ||
| updateCountOfProduct(product.getName(), product.getSize(), product.getStyle(), product.getAmount() + 1); | ||
| return getProductFromArrayList(product.getName(), product.getSize(), product.getStyle()); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -49,15 +45,31 @@ public Product addProduct(Product 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) | ||
| && product.getStyle().equals(style)) | ||
| 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); | ||
|
||
| 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); | ||
|
||
| products.remove(products.indexOf(updateProducht)); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,60 +6,49 @@ | |
| import com.xceptance.neodymium.util.Neodymium; | ||
|
|
||
| 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(); | ||
| }; | ||
|
||
|
|
||
| @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().isExpectedPage(); | ||
| } | ||
|
|
||
| @Step("open product page without cleared cookes") | ||
| public static ProductdetailPage openProductdetailsPage(String url) | ||
| // TODO check if needed - else delete | ||
|
||
| public static ProductDetailPage openProductDetailsPage(String url) | ||
| { | ||
| open(Neodymium.configuration().url() + url); | ||
| return new ProductdetailPage(); | ||
| return new ProductDetailPage().isExpectedPage(); | ||
| } | ||
| } | ||
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: if
updateCountOfProductwould return the updated product we could save the second line of codeThere 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.
Done