Skip to content

Commit 93edac8

Browse files
Refactor ApiE2eTest to simplify getOrder test and remove parameterized cases; add invalid quantity test cases in UiE2eTest
1 parent 7cc6627 commit 93edac8

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

system-test/src/test/java/com/optivem/atddaccelerator/eshop/systemtest/e2etests/ApiE2eTest.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ void placeOrder_shouldReturnOrderNumber() throws Exception {
6868
assertTrue(responseDto.getOrderNumber().startsWith("ORD-"), "Order number should start with ORD-");
6969
}
7070

71-
@ParameterizedTest
72-
@MethodSource("provideOrderTestCases")
73-
void getOrder_shouldReturnOrderDetails(long productId, int quantity) throws Exception {
71+
@Test
72+
void getOrder_shouldReturnOrderDetails() throws Exception {
7473
// Arrange - First place an order
74+
long productId = 11L;
75+
int quantity = 3;
76+
7577
var placeOrderRequest = new PlaceOrderRequest();
7678
placeOrderRequest.setProductId(String.valueOf(productId));
7779
placeOrderRequest.setQuantity(String.valueOf(quantity));
@@ -110,15 +112,6 @@ void getOrder_shouldReturnOrderDetails(long productId, int quantity) throws Exce
110112
assertNotNull(getOrderResponse.getTotalPrice(), "Total price should not be null");
111113
}
112114

113-
private static Stream<Arguments> provideOrderTestCases() {
114-
return Stream.of(
115-
Arguments.of(11L, 3), // Product 11 with standard quantity
116-
Arguments.of(12L, 5), // Product 12 with medium quantity
117-
Arguments.of(13L, 1), // Product 13 with minimum quantity
118-
Arguments.of(14L, 10) // Product 14 with large quantity
119-
);
120-
}
121-
122115
@Test
123116
void cancelOrder_shouldSetStatusToCancelled() throws Exception {
124117
// Arrange - First place an order

system-test/src/test/java/com/optivem/atddaccelerator/eshop/systemtest/e2etests/UiE2eTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ void shouldRejectOrderWithNegativeQuantity() {
217217
"Error message should indicate quantity must be positive. Actual: " + errorMessageText);
218218
}
219219

220+
private static Stream<Arguments> provideInvalidQuantityValues() {
221+
return Stream.of(
222+
Arguments.of("3.5"), // Decimal value
223+
Arguments.of("lala") // String value
224+
);
225+
}
226+
220227
@ParameterizedTest
221228
@MethodSource("provideInvalidQuantityValues")
222229
void shouldRejectOrderWithNonIntegerQuantity(String quantityValue) {
@@ -243,10 +250,10 @@ void shouldRejectOrderWithNonIntegerQuantity(String quantityValue) {
243250
"Error message should be 'Quantity must be an integer' for quantity: " + quantityValue + ". Actual: " + errorMessageText);
244251
}
245252

246-
private static Stream<Arguments> provideInvalidQuantityValues() {
253+
private static Stream<Arguments> provideInvalidProductIdValues() {
247254
return Stream.of(
248-
Arguments.of("3.5"), // Decimal value
249-
Arguments.of("lala") // String value
255+
Arguments.of("10.5"), // Decimal value
256+
Arguments.of("xyz") // String value
250257
);
251258
}
252259

@@ -275,11 +282,4 @@ void shouldRejectOrderWithNonIntegerProductId(String productIdValue) {
275282
assertTrue(errorMessageText.contains("Product ID must be an integer"),
276283
"Error message should be 'Product ID must be an integer' for productId: " + productIdValue + ". Actual: " + errorMessageText);
277284
}
278-
279-
private static Stream<Arguments> provideInvalidProductIdValues() {
280-
return Stream.of(
281-
Arguments.of("10.5"), // Decimal value
282-
Arguments.of("xyz") // String value
283-
);
284-
}
285285
}

0 commit comments

Comments
 (0)