-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated folder names to be in plural form.
- Loading branch information
Showing
13 changed files
with
52 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...g/com/smartinventory/entity/Customer.java → ...com/smartinventory/entities/Customer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sg/com/smartinventory/entity/Product.java → .../com/smartinventory/entities/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../sg/com/smartinventory/entity/Review.java → ...g/com/smartinventory/entities/Review.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...entory/repository/CustomerRepository.java → ...tory/repositories/CustomerRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ventory/repository/ProductRepository.java → ...ntory/repositories/ProductRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nventory/repository/ReviewRepository.java → ...entory/repositories/ReviewRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/sg/com/smartinventory/services/CustomerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,35 +14,38 @@ | |
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import sg.com.smartinventory.entity.Customer; | ||
import sg.com.smartinventory.entities.Customer; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
public class CustomerControllerTest { | ||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@DisplayName("Create customer") | ||
@Test | ||
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).email("[email protected]").reviewId(110).build(); | ||
|
||
// Step 2: Convert the Java object to JSON using ObjectMapper. | ||
String newCustomerAsJSON = objectMapper.writeValueAsString(newCustomer); | ||
|
||
// Step 3: Build the request. | ||
RequestBuilder request = MockMvcRequestBuilders.post("/customers").contentType(MediaType.APPLICATION_JSON) | ||
.content(newCustomerAsJSON); | ||
|
||
// Step 4: Perform the request and get the response and assert. | ||
mockMvc.perform(request).andExpect(status().isCreated()) | ||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(jsonPath("$.firstName").value("Jackie")).andExpect(jsonPath("$.lastName").value("Chan")); | ||
} | ||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
@DisplayName("Create customer") | ||
@Test | ||
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).email("[email protected]") | ||
.reviewId(110).build(); | ||
|
||
// Step 2: Convert the Java object to JSON using ObjectMapper. | ||
String newCustomerAsJSON = objectMapper.writeValueAsString(newCustomer); | ||
|
||
// Step 3: Build the request. | ||
RequestBuilder request = MockMvcRequestBuilders.post("/customers") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(newCustomerAsJSON); | ||
|
||
// Step 4: Perform the request and get the response and assert. | ||
mockMvc.perform(request).andExpect(status().isCreated()) | ||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(jsonPath("$.firstName").value("Jackie")) | ||
.andExpect(jsonPath("$.lastName").value("Chan")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ | |
class SmartInventoryApplicationTests { | ||
@Test | ||
void contextLoads() { | ||
|
||
} | ||
} |