Skip to content

Commit 7fa8ece

Browse files
authored
Revert "fix: updates build config and adjust tests (#458)"
This reverts commit d3fa849.
1 parent d3fa849 commit 7fa8ece

File tree

5 files changed

+10
-31
lines changed

5 files changed

+10
-31
lines changed

lesson_13/maps_java/maps_app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232

3333
application {
3434
// Define the main class for the application.
35-
mainClass.set("com.codedifferently.lesson13.Lesson13")
35+
mainClass.set("com.codedifferently.lesson12.Lesson12")
3636
}
3737

3838
tasks.named<Test>("test") {

lesson_14/exceptions/exceptions_app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232

3333
application {
3434
// Define the main class for the application.
35-
mainClass.set("com.codedifferently.lesson14.Lesson14")
35+
mainClass.set("com.codedifferently.lesson12.Lesson12")
3636
}
3737

3838
tasks.named<Test>("test") {

lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/EcommerceSystem.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.UUID;
66

77
public class EcommerceSystem {
8-
98
private Map<String, Product> products;
109
private Map<String, Order> orders;
1110

@@ -18,11 +17,8 @@ public void addProduct(String productId, String name) {
1817
products.put(productId, new Product(productId, name));
1918
}
2019

21-
public String placeOrder(String productId, int quantity) throws ProductNotFoundException {
20+
public String placeOrder(String productId, int quantity) {
2221
Product product = products.get(productId);
23-
if (product == null) {
24-
throw new ProductNotFoundException("Product with ID " + productId + " not found");
25-
}
2622
String orderId = UUID.randomUUID().toString();
2723
orders.put(orderId, new Order(orderId, product, quantity));
2824
return orderId;
@@ -32,11 +28,8 @@ public void cancelOrder(String orderId) {
3228
orders.remove(orderId);
3329
}
3430

35-
public String checkOrderStatus(String orderId) throws OrderNotFoundException {
31+
public String checkOrderStatus(String orderId) {
3632
Order order = orders.get(orderId);
37-
if (order == null) {
38-
throw new OrderNotFoundException("Order with ID " + orderId + " not found");
39-
}
4033
return "Order ID: "
4134
+ orderId
4235
+ ", Product: "

lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
33
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
44
*/
5-
package com.codedifferently.lesson14.ecommerce;
65

7-
class ProductNotFoundException extends RuntimeException {
6+
package com.codedifferently.lesson14.ecommerce;
87

9-
ProductNotFoundException(String message) {
10-
super(message);
11-
}
12-
}
8+
class ProductNotFoundException {}

lesson_14/exceptions/exceptions_app/src/test/java/com/codedifferently/lesson14/ecommerce/EcommerceSystemTest.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ void testPlaceOrder_productDoesNotExist() throws Exception {
4040
assertThatThrownBy(() -> ecommerceSystem.placeOrder("1", 1))
4141
.isInstanceOf(ProductNotFoundException.class)
4242
.hasMessage("Product with ID 1 not found");
43-
44-
// Act
45-
assertThatThrownBy(() -> ecommerceSystem.placeOrder("34", 1))
46-
.isInstanceOf(ProductNotFoundException.class)
47-
.hasMessage("Product with ID 34 not found");
4843
}
4944

5045
@Test
@@ -63,23 +58,18 @@ void testCheckOrderStatus_orderDoesNotExist() {
6358
assertThatThrownBy(() -> ecommerceSystem.checkOrderStatus("1"))
6459
.isInstanceOf(OrderNotFoundException.class)
6560
.hasMessage("Order with ID 1 not found");
66-
67-
// Act
68-
assertThatThrownBy(() -> ecommerceSystem.checkOrderStatus("33"))
69-
.isInstanceOf(OrderNotFoundException.class)
70-
.hasMessage("Order with ID 33 not found");
7161
}
7262

7363
@Test
7464
void testCheckOrderStatus_orderCancelled() throws Exception {
7565
// Arrange
76-
ecommerceSystem.addProduct("58", "Laptop");
77-
String orderId = ecommerceSystem.placeOrder("58", 1);
66+
ecommerceSystem.addProduct("1", "Laptop");
67+
String orderId = ecommerceSystem.placeOrder("1", 1);
7868
ecommerceSystem.cancelOrder(orderId);
7969

8070
// Act
81-
assertThatThrownBy(() -> ecommerceSystem.checkOrderStatus("58"))
71+
assertThatThrownBy(() -> ecommerceSystem.checkOrderStatus("1"))
8272
.isInstanceOf(OrderNotFoundException.class)
83-
.hasMessage("Order with ID 58 not found");
73+
.hasMessage("Order with ID 1 not found");
8474
}
8575
}

0 commit comments

Comments
 (0)