CoCoME System Tests

org.cocome.tradingsystem.systests.util
Class StockGenerator

java.lang.Object
  extended by org.cocome.tradingsystem.systests.util.StockGenerator

public class StockGenerator
extends java.lang.Object

This class is used to generate (reproducably) random stock items.

Version:
$Rev: 60 $
Author:
Benjamin Hummel, Christian Pfaller, $Author: pfaller $

Field Summary
private  java.util.List<GeneratedStockItem> generatedStock
          A list of all stock items generated so far.
private  ProductGenerator productGenerator
          The product generator containing all products we may refer to.
private  java.util.Random rng
          The random number generator used.
private  IStorePC storePC
          The storePC used for adding stock.
 
Constructor Summary
StockGenerator(long randomSeed, IStorePC storePC, ProductGenerator productGenerator)
          Construct a new stock generator.
 
Method Summary
private  void generate(int productIndex)
          Generate a single random stock item from the product of index i in the product generator.
 void generate(int productIndex, int minAmount, int amount, int maxAmount)
          Generate a single random stock item from the product of index i in the product generator with the given amounts in stock.
 void generateAll()
          Generate stock items for all known products.
 GeneratedStockItem getGeneratedStockItem(int i)
          Returns the stock item generated when i stock items had been generated already.
 int getNumberOfStockItems()
          Returns the number of stock items generated so far.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rng

private final java.util.Random rng
The random number generator used.


storePC

private final IStorePC storePC
The storePC used for adding stock.


productGenerator

private final ProductGenerator productGenerator
The product generator containing all products we may refer to.


generatedStock

private final java.util.List<GeneratedStockItem> generatedStock
A list of all stock items generated so far.

Constructor Detail

StockGenerator

public StockGenerator(long randomSeed,
                      IStorePC storePC,
                      ProductGenerator productGenerator)
Construct a new stock generator.

Parameters:
randomSeed - the random seed used for initializing the random number generator.
storePC - the store used for generating stock.
productGenerator - the product generator containing all products we may refer to.
Method Detail

getNumberOfStockItems

public int getNumberOfStockItems()
Returns the number of stock items generated so far.


getGeneratedStockItem

public GeneratedStockItem getGeneratedStockItem(int i)
Returns the stock item generated when i stock items had been generated already.


generateAll

public void generateAll()
                 throws java.lang.Exception
Generate stock items for all known products.

Throws:
java.lang.Exception

generate

private void generate(int productIndex)
               throws java.lang.Exception
Generate a single random stock item from the product of index i in the product generator.

Throws:
java.lang.Exception

generate

public void generate(int productIndex,
                     int minAmount,
                     int amount,
                     int maxAmount)
              throws java.lang.Exception
Generate a single random stock item from the product of index i in the product generator with the given amounts in stock.

Throws:
java.lang.Exception

CoCoME System Tests

CoCoME System Tests - 0.1