From: "Enrico Weigelt, metux IT consult" <[email protected]>
---
.../net/sf/freecol/common/model/BuildingTest.java | 29 +++++++++++++++++-----
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/test/src/net/sf/freecol/common/model/BuildingTest.java
b/test/src/net/sf/freecol/common/model/BuildingTest.java
index 92adb8eb592..bf74d7e4d33 100644
--- a/test/src/net/sf/freecol/common/model/BuildingTest.java
+++ b/test/src/net/sf/freecol/common/model/BuildingTest.java
@@ -175,6 +175,13 @@ public class BuildingTest extends FreeColTestCase {
assertEquals(0, b.getUnitCount());
}
+ private static boolean anyUnitIsType(List<Unit> units, UnitType unitType) {
+ for (Unit u : units)
+ if (u.getType() == unitType)
+ return true;
+ return false;
+ }
+
private void productionTest(BuildingType[] buildings, int[][][]values) {
Game game = getGame();
game.setMap(getTestMap(true));
@@ -200,11 +207,15 @@ public class BuildingTest extends FreeColTestCase {
indianConvertType, pettyCriminalType, indenturedServantType,
freeColonistType, building.getExpertUnitType() };
Tile tile = colony.getTile();
+
+ List<Unit> colonyUnits = colony.getUnits();
for (UnitType ut : unitTypes) {
- if (none(colony.getUnits(), matchKey(ut, Unit::getType))) {
- Unit u = find(colony.getUnits(),
- matchKey(freeColonistType, Unit::getType));
- u.changeType(ut);
+ if (anyUnitIsType(units, ut)) continue;
+ for (Unit u : colonyUnits) {
+ if (u.getType() == freeColonistType) {
+ u.changeType(ut);
+ break;
+ }
}
}
@@ -223,8 +234,14 @@ public class BuildingTest extends FreeColTestCase {
assertEquals(building.getType(), bt);
clearBuilding(building);
colony.setProductionBonus(level);
- Unit worker = find(colony.getUnits(),
- matchKey(ut, Unit::getType));
+ Unit worker = null;
+ for (Unit u : colony.getUnits()) {
+ if (u.getType() == ut) {
+ worker = u;
+ break;
+ }
+ }
+
assertNotNull(worker);
worker.setWorkType(outputType);
worker.setLocation(building);
--
2.11.0.rc0.7.gbe5a750
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Freecol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers