Skip to content

Commit

Permalink
Merge pull request #9 from nhkhai/main
Browse files Browse the repository at this point in the history
SIS-22: Updated ER Diagram to change mobile_no to phone_no.
  • Loading branch information
nhkhai authored Mar 21, 2024
2 parents f7a1799 + 1e38657 commit a45dc54
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
20 changes: 10 additions & 10 deletions Documentation/Diagrams/Entity Relationship Diagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,10 @@ erDiagram
string country
string address
int postal_code
int mobile_number
int phone_number
string email
}
Review {
long id PK
string category
string review_content
int rating
long customer_id FK
long product_id FK
}
Product {
long id PK
string category
Expand All @@ -29,6 +20,15 @@ erDiagram
int stock_quantity
}
Review {
long id PK
string category
string review_content
int rating
long customer_id FK
long product_id FK
}
Customer ||--O{ Review : "Has"
Product ||--O{ Review : "Has"
```
10 changes: 5 additions & 5 deletions src/main/java/sg/com/smartinventory/entities/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public class Customer {
@Column(name = "postal_code")
private int postalCode;

@Digits(fraction = 0, integer = 8, message = "Mobile no should be 8 digits. ")
@Column(name = "mobile_number")
private int mobileNumber;
@Digits(fraction = 0, integer = 8, message = "Phone no should be 8 digits. ")
@Column(name = "phone_number")
private int phoneNumber;

@Email(message = "Email should be valid. ")
@Column(name = "email")
Expand All @@ -57,7 +57,7 @@ public Customer() {
}

// Define Constructor for DataLoader.
public Customer(String firstName, String lastName, String country, String address, int postalCode, int mobileNumber,
public Customer(String firstName, String lastName, String country, String address, int postalCode, int phoneNumber,
String email) {
this();

Expand All @@ -66,7 +66,7 @@ public Customer(String firstName, String lastName, String country, String addres
this.country = country;
this.address = address;
this.postalCode = postalCode;
this.mobileNumber = mobileNumber;
this.phoneNumber = phoneNumber;
this.email = email;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sg.com.smartinventory.exceptions;

public class ProductNotFoundException extends RuntimeException {
public ProductNotFoundException(String id) {
public ProductNotFoundException(Long id) {
super("Could not find product with id: " + id + ". ");
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sg.com.smartinventory.exceptions;

public class ReviewNotFoundException extends RuntimeException {
public ReviewNotFoundException(String id) {
public ReviewNotFoundException(Long id) {
super("Could not find review with id: " + id + ". ");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void createCustomerTest() throws Exception {

// Step 1: Create a Customer object
Customer newCustomer = Customer.builder().firstName("Jackie").lastName("Chan").country("Hong Kong")
.address("123 HK St").postalCode(654321).mobileNumber(87654321)
.address("123 HK St").postalCode(654321).phoneNumber(87654321)
.email("[email protected]").build();

// Step 2: Convert the Java object to JSON using ObjectMapper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class IntegrationTest {
public void createCustomerTest() {
// 1. Setup.
Customer testObject1 = Customer.builder().firstName("Jackie").lastName("Chan").country("Hong Kong")
.address("123 HK St").postalCode(654321).mobileNumber(87654321)
.address("123 HK St").postalCode(654321).phoneNumber(87654321)
.email("[email protected]").build();

// mock the save method of the customer repository
Expand All @@ -69,10 +69,10 @@ public void createCustomerTest() {
public void runIntegratedTest() throws Exception {
// Step 1: Create the test objects.
Customer testObject1 = Customer.builder().firstName("Jackie").lastName("Chan").country("Hong Kong")
.address("123 HK St").postalCode(654321).mobileNumber(87654321)
.address("123 HK St").postalCode(654321).phoneNumber(87654321)
.email("[email protected]").build();
Customer testObject2 = Customer.builder().firstName("Jackie").lastName("Chang").country("Hong Kong")
.address("123 HK St").postalCode(654321).mobileNumber(87654321)
.address("123 HK St").postalCode(654321).phoneNumber(87654321)
.email("[email protected]").build();

// Step 2: Convert the Java objects to JSON using ObjectMapper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void createCustomerTest() {
// 1. SETUP
// Create a new customer.
Customer customer = Customer.builder().firstName("John").lastName("Wick").country("USA").address("123 Main St")
.postalCode(123456).mobileNumber(12345678).email("[email protected]").build();
.postalCode(123456).phoneNumber(12345678).email("[email protected]").build();

// Mock the save method of the customer repository.
when((customerRepository.save(customer))).thenReturn(customer);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class UseCaseTest {
public void createCustomerTest() {
// 1. Setup.
Customer testObject1 = Customer.builder().firstName("Jackie").lastName("Chan").country("Hong Kong")
.address("123 HK St").postalCode(654321).mobileNumber(87654321)
.address("123 HK St").postalCode(654321).phoneNumber(87654321)
.email("[email protected]").build();

// mock the save method of the customer repository
Expand All @@ -69,10 +69,10 @@ public void createCustomerTest() {
public void runIntegratedTest() throws Exception {
// Step 1: Create the test objects.
Customer testObject1 = Customer.builder().firstName("Jackie").lastName("Chan").country("Hong Kong")
.address("123 HK St").postalCode(654321).mobileNumber(87654321)
.address("123 HK St").postalCode(654321).phoneNumber(87654321)
.email("[email protected]").build();
Customer testObject2 = Customer.builder().firstName("Jackie").lastName("Chang").country("Hong Kong")
.address("123 HK St").postalCode(654321).mobileNumber(87654321)
.address("123 HK St").postalCode(654321).phoneNumber(87654321)
.email("[email protected]").build();

// Step 2: Convert the Java objects to JSON using ObjectMapper.
Expand Down

0 comments on commit a45dc54

Please sign in to comment.