Class StockServiceTest

    • Constructor Detail

      • StockServiceTest

        public StockServiceTest()
    • Method Detail

      • setUp

        public void setUp()
                   throws java.lang.Exception
        Setup of the test:
        • retrieves 3 products,
        • retrieves 3 warehouses.
        Throws:
        java.lang.Exception
      • testCreateStockLevel

        public void testCreateStockLevel()
        Tests the creation of stock levels.
        • creates stockLlevel1,
        • name, warehouse, availability, and history size check,
        • creates stockLevel2,
        • name, warehouse, availability, and history size check.
      • testCreateSameStockLevel

        public void testCreateSameStockLevel()
        Tests to create the same product in the same warehouse twice. The first time succeeds, and the second time throws a RuntimeException.
      • testTotalActualAmount

        public void testTotalActualAmount()
                                   throws BusinessException
        Tests the search for all stock levels and the total actual amount.
        • creates 3 stock levels: productCode1 in both warehouse1 and warehouse2, and productCode2 in warehouse2 only,
        • sets the first stock level as FORCE_IN_STOCK,
        • checks the result of the search for productCode1,
        • checks the result of the search for productCode1 in 3 specified warehouses,
        • creates another 2 stock levels: productCode1 and productCode3 in warehouse3,
        • checks the result of the search for productCode1 in 3 specified warehouses,
        • reserves productCode1, and test the negative stock level.
        Throws:
        BusinessException
      • testInStockStatus

        public void testInStockStatus()
        Tests the enabling and disabling of in stock function.
        • sets the status for a non-existing stock level, and there should be no exceptions,
        • creates the first stock level and enables in stock, and tests it,
        • creates another stock level and enables in stock, and tests it,
        • disables both stock levels, and test them.
      • testOutOfStock

        public void testOutOfStock()
        Tests the enabling and disabling of out of stock function.
        • sets the status for a non-existing stock level, and there should be no exceptions,
        • creates the first stock level and enables out of stock, and tests it,
        • creates another stock level and enables out of stock, and tests it,
        • disables both stock levels, and tests them
      • testProductStockStatus

        public void testProductStockStatus()
                                    throws BusinessException
        Tests stock level status.
        • creates a stock level, and tests the in stock status,
        • reserves the product, and tests the in stock status.
        Throws:
        BusinessException
      • testUpdateActualStockLevel

        public void testUpdateActualStockLevel()
                                        throws java.lang.Exception
        Tests actual stock level update.
        • creates a stock level, and updates the actual stock level with multi-threads,
        • thread pool: 50, and rounds: 150,
        • tests the stock level history entry size
        Throws:
        java.lang.Exception
      • testUpdateActualStockLevelNegativeAmount

        public void testUpdateActualStockLevelNegativeAmount()
        Test update actual stock level with negative amount. Should display warn in console.
      • testUpdateActualStockLevelZeroAmount

        public void testUpdateActualStockLevelZeroAmount()
        Test update actual stock level with zero amount. Should not display any text in the console.
      • testMultiReservations

        public void testMultiReservations()
                                   throws java.lang.Exception
        Tests stock level update of multi-reservations.
        • creates a stock level, and reserves the corresponding product with multi-threads,
        • thread pool: 200, and rounds: 600,
        • tests the total stock level history entry size,
        • tests reserved value of the last stock level history entry.
        Throws:
        java.lang.Exception
      • testUnsuccessfulReservations

        public void testUnsuccessfulReservations()
                                          throws BusinessException
        Tests an unsuccessful reservation and a successful one in sequence.
        • creates a stock level with 100 pieces in stock,
        • tries to reserve 200 pieces, must be unsuccessful,
        • tries to reserve 10 pieces, must be successful this time.
        Throws:
        BusinessException
      • testProductAvailability

        public void testProductAvailability()
        • Test of product availability by invoking default strategy for calculating product availability, passing product, quantity and warehouse/store as parameters,
        • Test of availability date by invoking default strategy for calculating product availability, passing product, quantity and warehouse/store as parameters (TODO),
        • Test of "bestOf" implementation
      • testCreateNoHistoryCreated

        public void testCreateNoHistoryCreated()
                                        throws java.lang.Exception
        Tests create stock level with no history created.
        Throws:
        java.lang.Exception
      • testReleaseNoHistoryCreated

        public void testReleaseNoHistoryCreated()
                                         throws BusinessException
        Tests release of stock level with no history created. Defaults to 0
        Throws:
        BusinessException
      • testReserveNoHistoryCreated

        public void testReserveNoHistoryCreated()
                                         throws java.lang.Exception
        Tests reserve stock level with no history created. Defaults to 0
        Throws:
        java.lang.Exception