Test Plan for Station Meal Component - UQcsse3200/2024-studio-3 GitHub Wiki
1. Introduction
This test plan outlines the test cases for the StationMealComponent class. The StationMealComponent is responsible for managing a meal preparation station in the game, including handling interactions between the player's inventory and the station's inventory, processing ingredients to create meals, and managing the rotation of items within the station.
2. Test Objectives
- Verify the correct initialization of the StationMealComponent
- Ensure proper handling of station inventory
- Test the addition and removal of items from the station
- Verify the functionality of meal creation
- Test the rotation of items in the station inventory
- Ensure correct interaction between player inventory and station inventory
- Test edge cases and error handling
3. Test Cases
3.1 Initialization Tests
3.1.1 Valid Initialization
- Test Method:
shouldSetAcceptableItems()
- Objective: Verify that the StationMealComponent initializes correctly with the specified acceptable items.
- Expected Result: The component should initialize with the correct list of acceptable items.
3.1.2 Station Type Setting
- Test Method:
shouldSetStationType()
- Objective: Ensure that the station type is set correctly during initialization.
- Expected Result: The
getType()
method should return the correct station type.
3.2 Item Acceptance Tests
3.2.1 Accept Valid Item
- Test Method:
shouldAcceptItem()
- Objective: Verify that the station accepts items that are in the list of acceptable items.
- Expected Result: The
isItemAccepted()
method should return true for valid items.
3.3 Meal Creation Tests
3.3.1 Insufficient Ingredients
- Test Method:
tooLittleShouldntMakeMeal()
- Objective: Ensure that a meal is not created when there are insufficient ingredients.
- Expected Result: No meal should be created in the station inventory.
3.3.2 No Meal Creation on Addition
- Test Method:
shouldntMakeMealWhenJustAdding()
- Objective: Verify that adding ingredients alone does not trigger meal creation.
- Expected Result: No meal should be created when ingredients are only added to the station.
3.3.3 Incorrect Ingredients
- Test Method:
incorrectIngrsShouldntMakeMeal()
- Objective: Ensure that a meal is not created when the ingredients do not match any recipe.
- Expected Result: No meal should be created with incorrect ingredient combinations.
3.3.4 Successful Meal Creation
- Test Methods:
shouldMakeAcaiBowl()
,shouldMakeBananaSplit()
,shouldMakeFruitSalad()
,shouldMakeSalad()
,shouldMakeSteakMeal()
- Objective: Verify that the correct meals are created with the right ingredient combinations.
- Expected Result: The specified meals should be created and added to the station inventory when the correct ingredients are combined.
3.4 Inventory Interaction Tests
3.4.1 Empty Inventories Interaction
- Test Method:
bothEmptyInventoriesShouldDoNothing()
- Objective: Ensure that no action is taken when both player and station inventories are empty.
- Expected Result: No changes should occur in either inventory.
3.4.2 Full Inventories Interaction
- Test Method:
bothFullInventoriesShouldDoNothing()
- Objective: Verify that no items are transferred when both inventories are full.
- Expected Result: No changes should occur in either inventory.
3.4.3 Transfer to Empty Station
- Test Method:
fullPlayerInventoryShouldTransferAcceptedItemToEmptyStation()
- Objective: Ensure that items are correctly transferred from a full player inventory to an empty station.
- Expected Result: The item should be moved from the player inventory to the station inventory.
3.4.4 Transfer to Non-Empty Station
- Test Method:
fullPlayerInventoryShouldTransferAcceptedItemToNonEmptyStation()
- Objective: Verify that items are correctly transferred from a full player inventory to a non-empty station.
- Expected Result: The item should be moved from the player inventory to the station inventory.
3.5 Item Retrieval Tests
3.5.1 Peek First Item
- Test Method:
peekShouldReturnFirstItemInStation()
- Objective: Ensure that the
peek()
method returns the first item in the station inventory. - Expected Result: The first item in the station inventory should be returned without removing it.
3.6 Meal Transfer Tests
3.6.1 Transfer Created Meal
- Test Method:
onlyMealShouldBeTransferredToPlayerWhenMealIsMade()
- Objective: Verify that only the created meal is transferred to the player inventory after meal creation.
- Expected Result: The created meal should be moved to the player inventory, leaving other items in the station.
3.7 Inventory Rotation Tests
3.7.1 Rotate Empty Inventory
- Test Method:
rotateEmptyInventoryShouldDoNothing()
- Objective: Ensure that rotating an empty inventory has no effect.
- Expected Result: The station inventory should remain empty after rotation.
3.7.2 Rotate Single Item Inventory
- Test Method:
rotateSingleItemInventoryShouldDoNothing()
- Objective: Verify that rotating an inventory with a single item has no effect.
- Expected Result: The single item should remain in the same position after rotation.
3.7.3 Rotate Multiple Items
- Test Method:
rotateMultipleItemsShouldChangeOrder()
- Objective: Ensure that rotating an inventory with multiple items changes their order correctly.
- Expected Result: The items should be reordered as specified by the rotation logic.
3.7.4 Rotate Full Inventory
- Test Method:
rotateFullInventoryShouldChangeOrder()
- Objective: Verify that rotating a full inventory changes the order of all items correctly.
- Expected Result: All items in the full inventory should be reordered as specified by the rotation logic.
4. Test Execution
All tests should be executed as part of the test suite in StationMealComponentTest.java. The testing framework (JUnit) will report on the success or failure of each test case.
5. Conclusion
This test plan covers the core functionality of the StationMealComponent, including initialization, item acceptance, meal creation, inventory interactions, and rotation. Successful execution of all test cases will provide confidence in the robustness and correctness of the StationMealComponent implementation.