Class ShippingRuleLoaderTest
java.lang.Object
test.ShippingRuleLoaderTest
Provides test cases for the
ShippingRuleLoader
class.
Tests the loading of shipping rules from JSON files, including the default rules and custom rules as well as testing error handling when the json file is not found or corrupted.
Contains the following test cases:
-
testLoadShippingRulesSuccessfully()
- Tests that shipping rules are loaded correctly from a JSON file with the correct parameters. -
testLoadDefaultShippingRules()
- Tests that the default shipping rules are loaded successfully. -
testLoadShippingRulesWithDimensionsAndWeight()
- Tests that all dimensions and weight limits are correctly loaded from the JSON file. -
testLoadShippingRulesWithEmptyJson()
- Tests that an empty JSON file throws aShippingRuleException
. -
testLoadShippingRulesWithCorruptedJson()
- Tests that a corrupted JSON file throws aShippingRuleException
. -
testShippingRulesAreSortedByCost()
- Tests that the rules are sorted by cost after loading. -
testLoadShippingRulesFileNotFound()
- Tests that aShippingRuleException
is thrown when the shipping rules file cannot be found.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Tests that the default shipping rules (from hardcoded path) are loaded successfully.void
Tests that an error is thrown when the shipping rules files cannot be found.void
Tests that shipping rules are loaded correctly from a JSON file.void
Tests that a corrupted JSON file throws an exception (e.g.void
Tests that all dimensions and weight limits are correctly loaded from the JSON file.void
Tests that an empty JSON file throws an exception.void
Tests that the rules are sorted by cost after loading (ascending order).
-
Constructor Details
-
ShippingRuleLoaderTest
public ShippingRuleLoaderTest()
-
-
Method Details
-
testLoadShippingRulesSuccessfully
-
testLoadDefaultShippingRules
@Test public void testLoadDefaultShippingRules()Tests that the default shipping rules (from hardcoded path) are loaded successfully. -
testLoadShippingRulesWithDimensionsAndWeight
-
testLoadShippingRulesWithEmptyJson
@Test public void testLoadShippingRulesWithEmptyJson()Tests that an empty JSON file throws an exception. -
testLoadShippingRulesWithCorruptedJson
@Test public void testLoadShippingRulesWithCorruptedJson()Tests that a corrupted JSON file throws an exception (e.g. missing closing bracket). -
testShippingRulesAreSortedByCost
-
testLoadShippingRulesFileNotFound
@Test public void testLoadShippingRulesFileNotFound()Tests that an error is thrown when the shipping rules files cannot be found.
-