@Test
    public void testIterateActiveLevels() {

        ao.setActiveLevels(new ArrayList<ILevel>());
        ILevel level = new LevelDecorator() {

            @Override
            public void conferAward() {
            }

            @Override
            public boolean hasPassedLevel() {
                return (Provider.getPlayer().getMoney() > 1000) ? true : false;
            }
        };
        final ILevel levelTwo = new LevelDecorator() {

            @Override
            public void conferAward() {
            }

            @Override
            public boolean hasPassedLevel() {
                return (Provider.getPlayer().getMoney() > 1000) ? true : false;
            }
        };

        level.setName("first level");
        levelTwo.setName("next level");

        final ArrayList<IAction> list = new ArrayList<IAction>();

        // Level not passed
        Provider.getPlayer().setMoney(0);
        assertFalse(level.hasPassedLevel());
        ao.iterateActiveLevels();

        // Level not passed but registered at event observer
        ao.registerLevel(level);
        Provider.getPlayer().setMoney(0);
        assertFalse(level.hasPassedLevel());
        ao.iterateActiveLevels();

        // Level passed
        Provider.getPlayer().setMoney(1500);
        assertTrue(level.hasPassedLevel());
        ao.iterateActiveLevels();

        // Level passed and next level available
        list.add(levelTwo);
        ((Action) level).setSuccessors(list);
        assertTrue(level.hasPassedLevel());
        assertTrue(ao.getActiveLevels().size() == 0);
        ao.getActiveLevels().add(0, level);
        assertTrue(ao.getActiveLevels().size() == 1);
        ao.iterateActiveLevels();
        assertTrue(ao.getActiveLevels().size() == 1);

        // Level pack passed and next level not available
        level = new LevelDecorator() {

            @Override
            public void conferAward() {
            }

            @Override
            public boolean hasPassedLevel() {
                return (Provider.getPlayer().getMoney() > 1000) ? true : false;
            }
        };
        assertTrue(level.hasPassedLevel());
        ao.setActiveLevels(new ArrayList<ILevel>());
        ao.getActiveLevels().add(level);
        ao.iterateActiveLevels();
        assertTrue(ao.getActiveLevels().size() == 0);

        // Test level specific events removal if level is passed
        level = new LevelDecorator() {

            @Override
            public void conferAward() {
            }

            @Override
            public boolean hasPassedLevel() {
                return (Provider.getPlayer().getMoney() > 1000) ? true : false;
            }
        };
        MainEvent event = new MainEvent();
        level.setEvents(new ArrayList<MainEvent>());
        level.getEvents().add(event);
        ao.setMainEvents(new ArrayList<MainEvent>());
        ao.getMainEvents().add(event);
        ao.setActiveLevels(new ArrayList<ILevel>());
        ao.registerLevel(level);
        Provider.getPlayer().setMoney(1500);
        assertTrue(level.hasPassedLevel());
        assertEquals(1, ao.getActiveLevels().size());
        assertEquals(1, ao.getMainEvents().size());
        ao.iterateActiveLevels();
        assertEquals(0, ao.getActiveLevels().size());
        assertEquals(0, ao.getMainEvents().size());

        // Test level pack specific events removal if level is passed
        ILevelPack levelPack = new LevelPack("my", "levelPack") {

            @Override
            public void initialize() {
            }
        };
        level = new LevelDecorator() {

            @Override
            public void conferAward() {
            }

            @Override
            public boolean hasPassedLevel() {
                return (Provider.getPlayer().getMoney() > 1000) ? true : false;
            }
        };
        event = new MainEvent();
        final MainEvent eventTwo = new MainEvent();
        levelPack.addFirstLevel(level);
        levelPack.setEvents(new ArrayList<MainEvent>());
        levelPack.getEvents().add(eventTwo);
        level.setEvents(new ArrayList<MainEvent>());
        level.getEvents().add(event);
        ao.setMainEvents(new ArrayList<MainEvent>());
        ao.getMainEvents().add(event);
        ao.getMainEvents().add(eventTwo);
        ao.setActiveLevels(new ArrayList<ILevel>());
        ao.registerLevel(level);
        Provider.getPlayer().setMoney(1500);
        assertTrue(level.hasPassedLevel());
        assertEquals(1, ao.getActiveLevels().size());
        assertEquals(2, ao.getMainEvents().size());
        ao.iterateActiveLevels();
        assertEquals(0, ao.getActiveLevels().size());
        assertEquals(0, ao.getMainEvents().size());

        // Test level specific tradeable removal if level is passed
        level = new LevelDecorator() {

            @Override
            public void conferAward() {
            }

            @Override
            public boolean hasPassedLevel() {
                return (Provider.getPlayer().getMoney() > 1000) ? true : false;
            }
        };
        Stock stock = new Stock();
        level.setTradeables(new ArrayList<ITradeable>());
        level.getTradeables().add(stock);
        TradeableHandler.getInstance().setActiveTradeables(new HashMap<ITradeable, Double>());
        TradeableHandler.getInstance().getActiveTradeables().put(stock, 0.0);
        ao.setActiveLevels(new ArrayList<ILevel>());
        ao.registerLevel(level);
        Provider.getPlayer().setMoney(1500);
        assertTrue(level.hasPassedLevel());
        assertEquals(1, ao.getActiveLevels().size());
        assertEquals(1, TradeableHandler.getInstance().getActiveTradeables().size());
        ao.iterateActiveLevels();
        assertEquals(0, ao.getActiveLevels().size());
        assertEquals(0, TradeableHandler.getInstance().getActiveTradeables().size());

        // Test level pack specific tradeable removal if level is passed
        levelPack = new LevelPack("my", "levelPack") {

            @Override
            public void initialize() {
            }
        };
        level = new LevelDecorator() {

            @Override
            public void conferAward() {
            }

            @Override
            public boolean hasPassedLevel() {
                return (Provider.getPlayer().getMoney() > 1000) ? true : false;
            }
        };
        stock = new Stock();
        final Commodity bond = new Commodity();
        levelPack.setTradeables(new ArrayList<ITradeable>());
        levelPack.getTradeables().add(bond);
        level.setLevelPack(levelPack);
        level.setTradeables(new ArrayList<ITradeable>());
        level.getTradeables().add(stock);
        TradeableHandler.getInstance().setActiveTradeables(new HashMap<ITradeable, Double>());
        TradeableHandler.getInstance().getActiveTradeables().put(stock, 0.0);
        TradeableHandler.getInstance().getActiveTradeables().put(bond, 0.0);
        ao.setActiveLevels(new ArrayList<ILevel>());
        ao.registerLevel(level);
        Provider.getPlayer().setMoney(1500);
        assertTrue(level.hasPassedLevel());
        assertEquals(1, ao.getActiveLevels().size());
        assertEquals(2, TradeableHandler.getInstance().getActiveTradeables().size());
        ao.iterateActiveLevels();
        assertEquals(0, ao.getActiveLevels().size());
        assertEquals(0, TradeableHandler.getInstance().getActiveTradeables().size());
    }