-
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.
Merge pull request #18 from nhkhai/main
Added skeleton for test case setup and cleanup.
- Loading branch information
Showing
15 changed files
with
319 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,21 @@ public DataLoader(CustomerRepository customerRepository, ProductRepository produ | |
|
||
@PostConstruct | ||
public void loadData() { | ||
// Clear all data. | ||
clearTableData(); | ||
|
||
// Create fake data. | ||
generateFakeData(); | ||
} | ||
|
||
public void clearTableData() { | ||
// Clear all data. | ||
customerRepository.deleteAll(); | ||
productRepository.deleteAll(); | ||
reviewRepository.deleteAll(); | ||
} | ||
|
||
public void generateFakeData() { | ||
// Create fake data. | ||
customerRepository.save(new Customer("John", "Doe", "USA", "123 Main St", 123456, 12345678, | ||
"[email protected]")); | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,9 @@ | |
|
||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
@@ -42,6 +44,16 @@ public class CustomerControllerTest { | |
private static final Logger test_logger = LoggerFactory.getLogger(CustomerControllerTest.class); | ||
|
||
// Test Setup and Teardown configuration. | ||
@BeforeAll | ||
static void initAll() { | ||
|
||
} | ||
|
||
@AfterAll | ||
static void teardownAll() { | ||
|
||
} | ||
|
||
@BeforeEach | ||
void init() { | ||
|
||
|
@@ -57,7 +69,7 @@ void teardown() { | |
public void createCustomerTest() throws Exception { | ||
test_logger.info("Starting test: " + getCurrentMethodName() + ". "); | ||
|
||
// Step 1: Create a Customer object | ||
// Step 1: Create a Customer object. | ||
Customer newCustomer = Customer.builder().firstName("Jackie").lastName("Chan").country("Hong Kong") | ||
.address("123 HK St").postalCode(654321).phoneNumber(87654321) | ||
.email("[email protected]").build(); | ||
|
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
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
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
Oops, something went wrong.