class RandomGenerator {

    public Map<Integer,List<List<Object>>> initialize(Long seed) {
    	int dbNo = 0;
    	
    	Random random = new Random(seed);
    	
    	for (int i=1;i<=prims.length;i++){
    		List<Object[]> availableDBs = dbExist.get(i-1);
			if (availableDBs!=null)
    			dbExist.put(i, new LinkedList<Object[]>(availableDBs));
    		else availableDBs = new LinkedList<Object[]>();
    		
    		int metaOperations = random.nextInt(MAX_META_OPERATIONS_PER_VIEWID-MIN_META_OPERATIONS_PER_VIEWID)+MIN_META_OPERATIONS_PER_VIEWID;
    		List<List<Object>> opsAtView = new LinkedList<List<Object>>();
    		
    		for (int y=0;y<metaOperations;y++){
        		availableDBs = dbExist.get(i);
    			if (availableDBs==null) availableDBs = new LinkedList<Object[]>();
    			List<Object> operation;
    			
    			// no DBs available jet --> make a create operation
    			if (availableDBs.size()<=1) {
    				operation = createOperation(random, dbNo, i);
    				dbNo++;
    			} else {
    				Operation op = Operation.values()[random.nextInt(Operation.values().length)];
    				
    				switch (op) {
    				case create:
    					operation = createOperation(random, dbNo, i);
        				dbNo++;
        				break;
    				case copy:
    					operation = copyOperation(random, dbNo, i);
    					dbNo++;
    					break;
    				case delete:
    					operation = deleteOperation(random, i);
    					break;
    				default:
    					throw new UnsupportedOperationException ("for "+op.toString());
    				}
    			}
    			opsAtView.add(operation);
    		}
    		operationsScenario.put(i, opsAtView);
    	}
    	
        Logging.logMessage(Logging.LEVEL_DEBUG, Category.babudb, this, "%s", this.toString());
    	
    	return operationsScenario;
    }

}

class RandomGeneratorTest {

    public static int NO_TESTS_PER_CASE;

    @Test
    public void testInitialize() {

        for (int i = 0; i < NO_TESTS_PER_CASE; i++) {
            long testSeed = RandomGenerator.getRandomSeed();
            assertEquals(new RandomGenerator().initialize(testSeed).toString(),
                    new RandomGenerator().initialize(testSeed).toString());
        }
    }

}