-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_Class
50 lines (45 loc) · 3.57 KB
/
Test_Class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
1). For this project, I have chosen to work within the inventory management domain.
This system will be designed to help businesses track and manage their stock of
products or resources. The primary purpose of the system is to ensure that an
organization has accurate and up-to-date information about its inventory levels,
reducing the chances of stock shortages or overstocking. It will enable users to
monitor product availability, track the addition of new stock, update product
information, and manage different types of inventory. I chose this domain because
inventory management is a crucial aspect of many businesses, and an efficient system
can significantly streamline operations, improve customer satisfaction, and reduce
operational costs. Additionally, the inventory management system provides a practical
and real-world application of using JPA (Java Persistence API) in NetBeans,
allowing me to better understand how to manage data persistence in business systems.
2). Although only one entity (such as Inventory) is required for Lab 4, there are several
other entities that could exist within an inventory management system. For example,
an Order entity could be used to track purchases or requests for products from inventory.
Similarly, a Supplier entity could be created to store information about vendors who
provide stock to the company, including details like supplier contact information and
delivery schedules. Additionally, a Customer entity could represent clients who are
purchasing products, and this would be linked to orders. These entities would interact
with one another in various ways. For example, an Order could be linked to both a
Customer (who placed the order) and the specific Inventory items that are being requested.
A Supplier would relate to the Inventory, as they provide the goods stocked in the
inventory. Together, these entities create a system that not only tracks the
quantity of products in stock but also manages the entire workflow from suppliers to
customers.
Test Class: `InventoryJPATest`
This test class verifies the following operations for the `Inventory` entity using JPA (Java Persistence API):
1. Create- Verifies that an `Inventory` entity can be successfully persisted.
2. Read- Verifies that an `Inventory` entity can be retrieved.
3. Update- Verifies that an `Inventory` entity can be updated.
4. Delete- Verifies that an `Inventory` entity can be deleted.
Console Output:
text:
beforeEach with inventory:Inventory{id=1, name=TEST DATA, productionDate=2020-12-12, type=FLOAT}
afterEach with inventory:Inventory{id=1, name=TEST DATA, productionDate=2020-12-12, type=FLOAT}
beforeEach with inventory:Inventory{id=2, name=TEST DATA, productionDate=2020-12-12, type=FLOAT}
afterEach with inventory:Inventory{id=2, name=TEST DATA, productionDate=2021-01-01, type=FLOAT}
beforeEach with inventory:Inventory{id=3, name=TEST DATA, productionDate=2020-12-12, type=FLOAT}
afterEach with inventory:Inventory{id=3, name=TEST DATA, productionDate=2020-12-12, type=FLOAT}
beforeEach with inventory:Inventory{id=5, name=TEST DATA, productionDate=2020-12-12, type=FLOAT}
Testing invalid future production date: Inventory{id=null, name=Test Window, productionDate=2030-01-01, type=FLOAT}
Validation message: must be a date in the past or in the present
Valid Inventory: Inventory{id=null, name=Test Window, productionDate=2020-12-12, type=FLOAT}
Testing invalid blank name: Inventory{id=null, name=, productionDate=2020-12-12, type=INSULATED}
Validation message: must not be blank