public void testConsumers() {

    Game game = getGame();
    game.setMap(getTestMap());

    Colony colony = getStandardColony(3);
    int units = colony.getUnitCount();
    int buildings = colony.getBuildings().size();

    List<Consumer> consumers = colony.getConsumers();

    // units come first
    for (int index = 0; index < units; index++) {
      assertTrue(consumers.get(index).toString(), consumers.get(index) instanceof Unit);
    }
    // buildings come next
    for (int index = units; index < units + buildings; index++) {
      assertTrue(consumers.get(index).toString(), consumers.get(index) instanceof Building);
    }
    // build and population queues come last
    for (int index = units + buildings; index < units + buildings + 2; index++) {
      assertTrue(consumers.get(index).toString(), consumers.get(index) instanceof BuildQueue);
    }

    Building country = colony.getBuilding(countryType);
    assertTrue(consumers.contains(country));

    Building depot = colony.getBuilding(depotType);
    assertTrue(consumers.contains(depot));

    int countryIndex = consumers.indexOf(country);
    int depotIndex = consumers.indexOf(depot);
    assertTrue(countryIndex >= 0);
    assertTrue(depotIndex >= 0);
    assertTrue(
        "Priority of depot should be higher than that of country", depotIndex < countryIndex);

    BuildingType armoryType = spec().getBuildingType("model.building.armory");
    Building armory = new ServerBuilding(getGame(), colony, armoryType);
    colony.addBuilding(armory);
    consumers = colony.getConsumers();

    // units come first
    for (int index = 0; index < units; index++) {
      assertTrue(consumers.get(index).toString(), consumers.get(index) instanceof Unit);
    }
    int offset = units + buildings;
    // buildings come next
    for (int index = units; index < offset; index++) {
      assertTrue(consumers.get(index).toString(), consumers.get(index) instanceof Building);
    }
    // build queue comes last
    assertTrue(consumers.get(offset).toString(), consumers.get(offset) instanceof BuildQueue);
    // armory has a lower priority than the build queue
    assertTrue(consumers.get(offset + 1).toString(), consumers.get(offset + 1) instanceof Building);
    assertEquals(armoryType, ((Building) consumers.get(offset + 1)).getType());
    // population queue comes last
    assertTrue(
        consumers.get(offset + 2).toString(), consumers.get(offset + 2) instanceof BuildQueue);
  }
  /**
   * Tests that there is no over production of horses, to avoid them being thrown out. A test of the
   * proper production of horses is in <code>BuildingTest</code>
   */
  public void testNoHorsesOverProduction() {
    Game game = getGame();
    game.setMap(getTestMap());

    Colony colony = getStandardColony(1);

    Building pasture = colony.getBuilding(countryType);
    assertEquals(horsesType, pasture.getGoodsOutputType());
    assertEquals(
        "Wrong warehouse capacity in colony",
        GoodsContainer.CARGO_SIZE,
        colony.getWarehouseCapacity());

    // Still room for more
    colony.addGoods(horsesType, 99);
    assertTrue(colony.getNetProductionOf(foodType) > 0);

    assertEquals("Wrong horse production", 1, pasture.getTotalProductionOf(horsesType));
    assertEquals("Wrong maximum horse production", 1, pasture.getMaximumProductionOf(horsesType));
    assertEquals("Wrong net horse production", 1, colony.getNetProductionOf(horsesType));

    // No more room available
    colony.addGoods(horsesType, 1);
    assertEquals(
        "Wrong number of horses in colony",
        colony.getWarehouseCapacity(),
        colony.getGoodsCount(horsesType));
    assertEquals("Wrong horse production", 0, pasture.getTotalProductionOf(horsesType));
    assertEquals("Wrong maximum horse production", 0, pasture.getMaximumProductionOf(horsesType));
    assertEquals("Wrong net horse production", 0, colony.getNetProductionOf(horsesType));
  }
  public void testGetPotentialProduction() {
    Game game = getGame();
    game.setMap(getTestMap());

    Colony colony = getStandardColony(1);
    ColonyTile colonyTile = colony.getColonyTile(colony.getTile());
    assertNotNull(colonyTile);
    assertEquals(plainsType, colony.getTile().getType());
    Building townHall = colony.getBuilding(townHallType);
    assertNotNull(townHall);
    UnitType colonistType = spec().getDefaultUnitType();
    assertNotNull(colonistType);

    assertEquals(
        "Zero potential production of cotton in town hall",
        0,
        townHall.getPotentialProduction(cottonType, colonistType));
    assertEquals(
        "Basic potential production of bells in town hall",
        (int)
            FeatureContainer.applyModifiers(
                0f, game.getTurn(), townHall.getProductionModifiers(bellsType, colonistType)),
        townHall.getPotentialProduction(bellsType, colonistType));

    assertEquals(
        "Basic potential production of cotton on center tile" + " if not using a unit",
        plainsType.getProductionOf(cottonType, null),
        colonyTile.getPotentialProduction(cottonType, null));
    assertEquals(
        "Zero potential production of cotton on center tile" + " if using a unit",
        0,
        colonyTile.getPotentialProduction(cottonType, colonistType));
    assertEquals(
        "Zero potential production of cotton in town hall",
        0,
        townHall.getPotentialProduction(cottonType, colonistType));
  }