Class StockServiceTest

All Implemented Interfaces:
JaloSessionHolder

public class StockServiceTest extends ServicelayerTest
Test for StockService
  • Constructor Details

    • StockServiceTest

      public StockServiceTest()
  • Method Details

    • setUp

      public void setUp() throws Exception
      Setup of the test:
      • retrieves 3 products,
      • retrieves 3 warehouses.
      Throws:
      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 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:
      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.
    • testRelease

      public void testRelease() throws BusinessException
      Tests release of stock level.
      Throws:
      BusinessException
    • testMultiReservations

      public void testMultiReservations() throws 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:
      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
    • testSuccessfulReservations

      public void testSuccessfulReservations() throws BusinessException
      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 Exception
      Tests create stock level with no history created.
      Throws:
      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 Exception
      Tests reserve stock level with no history created. Defaults to 0
      Throws:
      Exception