Package de.hybris.platform.stock
Class StockServiceTest
- java.lang.Object
-
- de.hybris.platform.testframework.HybrisJUnit4Test
-
- de.hybris.platform.servicelayer.ServicelayerBaseTest
-
- de.hybris.platform.servicelayer.ServicelayerTest
-
- de.hybris.platform.stock.StockServiceTest
-
- All Implemented Interfaces:
JaloSessionHolder
public class StockServiceTest extends ServicelayerTest
Test forStockService
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.ServicelayerTest
importService
-
Fields inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
jaloSession
-
-
Constructor Summary
Constructors Constructor Description StockServiceTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetUp()Setup of the test: retrieves 3 products, retrieves 3 warehouses.voidtestCreateNoHistoryCreated()Tests create stock level with no history created.voidtestCreateSameStockLevel()Tests to create the same product in the same warehouse twice.voidtestCreateStockLevel()Tests the creation of stock levels.voidtestInStockStatus()Tests the enabling and disabling of in stock function.voidtestMultiReservations()Tests stock level update of multi-reservations.voidtestOutOfStock()Tests the enabling and disabling of out of stock function.voidtestProductAvailability()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" implementationvoidtestProductStockStatus()Tests stock level status.voidtestRelease()Tests release of stock level.voidtestReleaseNoHistoryCreated()Tests release of stock level with no history created.voidtestReserveNoHistoryCreated()Tests reserve stock level with no history created.voidtestSuccessfulReservations()voidtestTotalActualAmount()Tests the search for all stock levels and the total actual amount.voidtestUnsuccessfulReservations()Tests an unsuccessful reservation and a successful one in sequence.voidtestUpdateActualStockLevel()Tests actual stock level update.voidtestUpdateActualStockLevelNegativeAmount()Test update actual stock level with negative amount.voidtestUpdateActualStockLevelZeroAmount()Test update actual stock level with zero amount.-
Methods inherited from class de.hybris.platform.servicelayer.ServicelayerTest
createCoreData, createDefaultCatalog, createDefaultUsers, createHardwareCatalog, getApplicationContext, importCsv, importData, importData, importData, importStream, importStream, isPrefetchModeNone
-
Methods inherited from class de.hybris.platform.servicelayer.ServicelayerBaseTest
autowireProperties, getBeanName, prepareApplicationContextAndSession
-
Methods inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
establishJaloSession, finish, getOrCreateCurrency, getOrCreateLanguage, init, intenseChecksActivated, takeJaloSession
-
-
-
-
Method Detail
-
setUp
public void setUp() throws java.lang.ExceptionSetup 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 BusinessExceptionTests 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 BusinessExceptionTests 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.ExceptionTests 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.
-
testRelease
public void testRelease() throws BusinessExceptionTests release of stock level.- Throws:
BusinessException
-
testMultiReservations
public void testMultiReservations() throws java.lang.ExceptionTests 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 BusinessExceptionTests 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 java.lang.ExceptionTests create stock level with no history created.- Throws:
java.lang.Exception
-
testReleaseNoHistoryCreated
public void testReleaseNoHistoryCreated() throws BusinessExceptionTests release of stock level with no history created. Defaults to 0- Throws:
BusinessException
-
testReserveNoHistoryCreated
public void testReserveNoHistoryCreated() throws java.lang.ExceptionTests reserve stock level with no history created. Defaults to 0- Throws:
java.lang.Exception
-
-