-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservicesFilteredByYear.java
236 lines (168 loc) · 9.7 KB
/
servicesFilteredByYear.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
package main.tests.allTests.widget.widget_Web.servicesFilteredByYear;
import main.all.common.objects.tireSize.TireSize;
import main.api.Api;
import main.api.v2.requests.routes.location.getLocation.objects.data.Location;
import main.api.v2.requests.routes.quote.abstractQuote.parameters.QuoteRequestParameters;
import main.api.v2.requests.routes.quote.quoteDisplay.DisplayQuoteRequest;
import main.api.v2.requests.routes.tire.search.searches.bySize.response.objects.data.tires.Tire_SearchBySize;
import main.api.v2.requests.routes.vehicle.tireSizes.TireSizesRequest;
import main.environments.classes.entities.main.ApiKey;
import main.environments.data.clients.allClients.all.Clients;
import main.tests.allTests.widget.SettingsForDriver;
import main.widget.Widget;
import main.widget.pages.CommonWidgetMethods;
import main.widget.pages.wigetPages.summaryPage.SummaryPage;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
public class servicesFilteredByYear extends SettingsForDriver {
private ApiKey apiKey = new Clients().clientDefault().dealerServicesFilterByYear().getApiKeys().getWidgetApiKey_en_US();
private Location location = new Api().v2().locationList().list(apiKey).getResponse().getRandomLocation();
private Tire_SearchBySize tire;
private String carTireId;
private QuoteRequestParameters quoteRequestParameters;
private DisplayQuoteRequest display;
@Test
public void checkServicesFilteredByYear_2016(){
getCarTireId("2016", "BMW", "228i", "Coupe");
setTire("205", "50", "17");
SummaryPage summaryPage = new Widget().web().summaryPage().byVehicle().getPage(driver, apiKey, location.getId().toString(),
tire.getId(), "2", "2016", "BMW", "228i", "Coupe", carTireId);
parametersForRequest("2");
quoteDisplayRequestToApi();
Assert.assertTrue(display.getResponse().getData().getServices().size()==3);
checkServicesFromApi(display, 0, "99.0", "Year_Testing_Service >= 2016");
checkServicesFromApi(display, 1, "80.0", "Year_Testing_Service >= 1998-2016");
checkServicesFromApi(display, 2, "100.0", "Year_Testing_Services >= 1980 - 2018");
checkServicesFront(summaryPage, "2016");
checkServicesFront(summaryPage, "1998-2016");
checkServicesFront(summaryPage, "1980 - 2018");
}
@Test
public void checkServicesFilteredByYear_2015(){
getCarTireId("2015", "BMW", "740i", "Base");
setTire("195", "65", "15");
SummaryPage summaryPage = new Widget().web().summaryPage().byVehicle().getPage(driver, apiKey, location.getId().toString(),
tire.getId(), "2", "2015", "BMW", "740i", "Base", carTireId);
parametersForRequest("2");
quoteDisplayRequestToApi();
Assert.assertTrue(display.getResponse().getData().getServices().size()==2);
checkServicesFromApi(display, 0, "80.0", "Year_Testing_Service >= 1998-2016");
checkServicesFromApi(display, 1, "100.0", "Year_Testing_Services >= 1980 - 2018");
checkServicesFront(summaryPage, "1998-2016");
checkServicesFront(summaryPage, "1980 - 2018");
}
@Test
public void checkServicesFilteredByYear_1990(){
getCarTireId("1990", "BMW", "525i", "Base");
setTire("205", "65", "15");
SummaryPage summaryPage = new Widget().web().summaryPage().byVehicle().getPage(driver, apiKey, location.getId().toString(),
tire.getId(), "2", "1990", "BMW", "525i", "Base", carTireId);
parametersForRequest("2");
quoteDisplayRequestToApi();
Assert.assertTrue(display.getResponse().getData().getServices().size()==3);
checkServicesFromApi(display, 0, "80.0", "Year_Testing_Services =< 2000");
checkServicesFromApi(display, 1, "70.0", "Year_Testing_Services >= 1980 - 1993");
checkServicesFromApi(display, 2, "100.0", "Year_Testing_Services >= 1980 - 2018");
checkServicesFront(summaryPage, "2000");
checkServicesFront(summaryPage, "1980 - 1993");
checkServicesFront(summaryPage, "1980 - 2018");
}
@Test
public void checkServicesFilteredByYear_2004(){
getCarTireId("2004", "Audi", "A6", "3.0");
setTire("205", "55", "16");
SummaryPage summaryPage = new Widget().web().summaryPage().byVehicle().getPage(driver, apiKey, location.getId().toString(),
tire.getId(), "2", "2004", "Audi", "A6", "3.0", carTireId);
parametersForRequest("2");
quoteDisplayRequestToApi();
Assert.assertTrue(display.getResponse().getData().getServices().size()==3);
checkServicesFromApi(display, 0, "80.0", "Year_Testing_Service >= 1998-2016");
checkServicesFromApi(display, 1, "100.0", "Year_Testing_Services >= 1980 - 2018");
checkServicesFromApi(display, 2, "110.0", "Year_Testing_Services >= 1998 - 2004");
checkServicesFront(summaryPage, "1998-2016");
checkServicesFront(summaryPage, "1980 - 2018");
checkServicesFront(summaryPage, "1998 - 2004");
}
// tests with select vehicle on summary page
@Test
public void checkServicesFilteredByYear_2004_WithSelectVehicle(){
setTire("205", "55", "16");
SummaryPage summaryPage = new Widget().web().summaryPage().getPage(driver, apiKey, tire);
summaryPage.waitForLoadPageSelectVehicle();
setVehicle(driver, "2004", "Audi", "A6", "3.0");
summaryPage.clickSeeOutDoorThePriceOnThePageSelectVehicle();
summaryPage.changeQuantity("2");
checkServicesFront(summaryPage, "1998-2016");
checkServicesFront(summaryPage, "1980 - 2018");
checkServicesFront(summaryPage, "1998 - 2004");
}
@Test
public void checkServicesFilteredByYear_1990_WithSelectVehicle(){
setTire("205", "65", "15");
SummaryPage summaryPage = new Widget().web().summaryPage().getPage(driver, apiKey, tire);
summaryPage.waitForLoadPageSelectVehicle();
setVehicle(driver, "1990", "BMW", "525i", "Base");
summaryPage.clickSeeOutDoorThePriceOnThePageSelectVehicle();
summaryPage.changeQuantity("2");
checkServicesFront(summaryPage, "2000");
checkServicesFront(summaryPage, "1980 - 1993");
checkServicesFront(summaryPage, "1980 - 2018");
}
@Test
public void checkServicesFilteredByYear_2015_WithSelectVehicle(){
setTire("195", "65", "15");
SummaryPage summaryPage = new Widget().web().summaryPage().getPage(driver, apiKey, tire);
summaryPage.waitForLoadPageSelectVehicle();
setVehicle(driver, "2015", "BMW", "740i", "Base");
summaryPage.clickSeeOutDoorThePriceOnThePageSelectVehicle();
summaryPage.changeQuantity("2");
checkServicesFront(summaryPage, "1998-2016");
checkServicesFront(summaryPage, "1980 - 2018");
}
@Test
public void checkServicesFilteredByYear_2016_WithSelectVehicle(){
setTire("205", "50", "17");
SummaryPage summaryPage = new Widget().web().summaryPage().getPage(driver, apiKey, tire);
summaryPage.waitForLoadPageSelectVehicle();
setVehicle(driver, "2016", "BMW", "228i", "Coupe");
summaryPage.clickSeeOutDoorThePriceOnThePageSelectVehicle();
summaryPage.changeQuantity("2");
checkServicesFront(summaryPage, "2016");
checkServicesFront(summaryPage, "1998-2016");
checkServicesFront(summaryPage, "1980 - 2018");
}
private static synchronized void setVehicle(WebDriver driver, String year, String make, String model, String trim){
CommonWidgetMethods.setYear(driver, year);
CommonWidgetMethods.setMake(driver, make);
CommonWidgetMethods.setModel(driver, model);
CommonWidgetMethods.setTrim(driver, trim);
}
private void getCarTireId(String year, String make, String model, String trim){
TireSizesRequest tireSizesRequest = new Api().v2().vehicleTireSizes().tireSizes(apiKey, year, make, model, trim);
carTireId = tireSizesRequest.getResponse().getRandomCarTire().getId();
}
private void setTire(String width, String height, String rim) {
setTire(new TireSize(width, height, rim));
}
private void setTire(TireSize tireSize) {
tire = new Api().v2().tireSearchBySize().bySize(apiKey, tireSize).getResponse().getRandomTireWithQuantity(2);
}
private void quoteDisplayRequestToApi(){
display = new Api().v2().quoteDisplay().display(apiKey, quoteRequestParameters);
}
private void parametersForRequest(String quantity){
quoteRequestParameters = new QuoteRequestParameters();
quoteRequestParameters.setVehicleCarTireId(carTireId);
quoteRequestParameters.addTireId(tire.getId());
quoteRequestParameters.addQuantity(quantity);
}
private void checkServicesFront(SummaryPage summaryPage, String partTextOfServices){
Assert.assertTrue(summaryPage.getTextAnyServicesFromSummaryPage(partTextOfServices).contains(partTextOfServices));
}
private void checkServicesFromApi(DisplayQuoteRequest display, int numberOfServicesFromApi, String summService, String nameAndDescription){
Assert.assertEquals(summService, display.getResponse().getData().getServices().get(numberOfServicesFromApi).getTotal_price().toString());
Assert.assertEquals(nameAndDescription, display.getResponse().getData().getServices().get(numberOfServicesFromApi).getName());
Assert.assertEquals(nameAndDescription, display.getResponse().getData().getServices().get(numberOfServicesFromApi).getDescription());
}
}