@Test public void testIsGoalMet() { World world = new WorldImpl(10, 10, null, null); WorldObject performer = createPerformer(2); assertEquals(true, goal.isGoalMet(performer, world)); performer.getProperty(Constants.INVENTORY).addQuantity(Item.WOOD.generate(1f), 10); assertEquals(false, goal.isGoalMet(performer, world)); }
@Test public void testCalculateGoalNull() { World world = new WorldImpl(1, 1, null, null); WorldObject performer = createPerformer(2); assertEquals(null, goal.calculateGoal(performer, world)); }
@Test public void testCalculateGoalSell() { World world = new WorldImpl(10, 10, null, null); WorldObject performer = createPerformer(2); WorldObject target = createPerformer(3); world.addWorldObject(performer); world.addWorldObject(target); performer.setProperty(Constants.GOLD, 100); performer.getProperty(Constants.INVENTORY).addQuantity(Item.WOOD.generate(1f), 20); target.setProperty(Constants.GOLD, 100); target.setProperty(Constants.DEMANDS, new PropertyCountMap<>()); target.getProperty(Constants.DEMANDS).add(Constants.WOOD, 1); assertEquals(Actions.SELL_ACTION, goal.calculateGoal(performer, world).getManagedOperation()); assertEquals(target, goal.calculateGoal(performer, world).getTarget()); }