Class ShippingRuleLoaderTest

java.lang.Object
test.ShippingRuleLoaderTest

public class ShippingRuleLoaderTest extends Object
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:

See Also:
  • Constructor Details

    • ShippingRuleLoaderTest

      public ShippingRuleLoaderTest()
  • Method Details

    • testLoadShippingRulesSuccessfully

      @Test public void testLoadShippingRulesSuccessfully() throws Exception
      Tests that shipping rules are loaded correctly from a JSON file.
      Throws:
      Exception
    • testLoadDefaultShippingRules

      @Test public void testLoadDefaultShippingRules()
      Tests that the default shipping rules (from hardcoded path) are loaded successfully.
    • testLoadShippingRulesWithDimensionsAndWeight

      @Test public void testLoadShippingRulesWithDimensionsAndWeight() throws Exception
      Tests that all dimensions and weight limits are correctly loaded from the JSON file.
      Throws:
      Exception
    • 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

      @Test public void testShippingRulesAreSortedByCost() throws Exception
      Tests that the rules are sorted by cost after loading (ascending order).
      Throws:
      Exception
    • testLoadShippingRulesFileNotFound

      @Test public void testLoadShippingRulesFileNotFound()
      Tests that an error is thrown when the shipping rules files cannot be found.