@Test
  public void testPerformerCanAttackCriminals() {
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.CAN_ATTACK_CRIMINALS, Boolean.TRUE);

    assertEquals(true, DefaultGoalObstructedHandler.performerCanAttackCriminals(performer));

    performer = TestUtils.createIntelligentWorldObject(1, Constants.FOOD, 500);
    assertEquals(false, DefaultGoalObstructedHandler.performerCanAttackCriminals(performer));
  }
 @Test
 public void testPerformerAttacked() {
   assertEquals(true, DefaultGoalObstructedHandler.performerAttacked(Actions.MELEE_ATTACK_ACTION));
   assertEquals(
       true,
       DefaultGoalObstructedHandler.performerAttacked(Actions.NON_LETHAL_MELEE_ATTACK_ACTION));
   assertEquals(
       true, DefaultGoalObstructedHandler.performerAttacked(Actions.FIRE_BOLT_ATTACK_ACTION));
   assertEquals(false, DefaultGoalObstructedHandler.performerAttacked(Actions.CURE_POISON_ACTION));
 }
  @Test
  public void testActionTargetIsCriminal() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject organization = createVillagersOrganization(world);

    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.GROUP, new IdList());
    assertEquals(true, DefaultGoalObstructedHandler.actionTargetIsCriminal(performer, world));

    performer.getProperty(Constants.GROUP).add(organization);
    assertEquals(false, DefaultGoalObstructedHandler.actionTargetIsCriminal(performer, world));
  }
  @Test
  public void testAlterRelationships() {
    World world = new WorldImpl(1, 1, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(1, Constants.GENDER, "male");
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList());
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);
    WorldObject villagersOrganization = createVillagersOrganization(world);

    performer.setProperty(Constants.GROUP, new IdList().add(villagersOrganization));

    DefaultGoalObstructedHandler.alterRelationships(
        performer,
        actionTarget,
        actionTarget,
        null,
        Actions.MELEE_ATTACK_ACTION,
        world,
        -10,
        performer,
        actionTarget);

    assertEquals(-10, performer.getProperty(Constants.RELATIONSHIPS).getValue(actionTarget));
    assertEquals(-10, actionTarget.getProperty(Constants.RELATIONSHIPS).getValue(performer));
    assertEquals(true, actionTarget.getProperty(Constants.GROUP).getIds().isEmpty());
  }
  @Test
  public void testAreBrawling() {
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.BRAWL_OPPONENT_ID, 2);
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.BRAWL_OPPONENT_ID, 1);

    assertEquals(
        true,
        DefaultGoalObstructedHandler.areBrawling(
            performer, actionTarget, Actions.NON_LETHAL_MELEE_ATTACK_ACTION));
    assertEquals(
        false,
        DefaultGoalObstructedHandler.areBrawling(
            performer, actionTarget, Actions.MELEE_ATTACK_ACTION));
  }
  @Test
  public void testCalculateTargetNoDeception() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(2, "performer");
    WorldObject target = TestUtils.createIntelligentWorldObject(3, "target");

    assertEquals(target, DefaultGoalObstructedHandler.calculateTarget(performer, target, world));
  }
  @Test
  public void testPerformerViolatedGroupRules() {
    World world = new WorldImpl(10, 10, null, null);
    createVillagersOrganization(world);
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.GROUP, new IdList().add(1));
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList().add(1));

    assertEquals(
        false,
        DefaultGoalObstructedHandler.performerViolatedGroupRules(
            performer, actionTarget, null, Actions.TALK_ACTION, world));
    assertEquals(
        true,
        DefaultGoalObstructedHandler.performerViolatedGroupRules(
            performer, actionTarget, null, Actions.MELEE_ATTACK_ACTION, world));
  }
  @Test
  public void testAreFightingInArenaNoFight() {
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.ARENA_OPPONENT_ID, null);
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.ARENA_OPPONENT_ID, null);

    assertEquals(
        false, DefaultGoalObstructedHandler.areFightingInArena(performer, actionTarget, null));
  }
  @Test
  public void testCalculateTargetDisguised() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(2, "performer");
    WorldObject target = TestUtils.createIntelligentWorldObject(3, "target");
    WorldObject disguise = TestUtils.createIntelligentWorldObject(4, "disguise");
    world.addWorldObject(disguise);

    FacadeUtils.disguise(target, disguise.getProperty(Constants.ID), world);
    performer.setProperty(Constants.KNOWLEDGE_MAP, new KnowledgeMap());

    assertEquals(disguise, DefaultGoalObstructedHandler.calculateTarget(performer, target, world));
  }
  @Test
  public void testAreBrawlingItemEquiped() {
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.BRAWL_OPPONENT_ID, 2);
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.BRAWL_OPPONENT_ID, 1);

    performer.setProperty(Constants.LEFT_HAND_EQUIPMENT, Item.IRON_CLAYMORE.generate(1f));

    assertEquals(
        false,
        DefaultGoalObstructedHandler.areBrawling(
            performer, actionTarget, Actions.NON_LETHAL_MELEE_ATTACK_ACTION));
  }
  @Test
  public void testCalculateTargetMaskedIllusion() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(2, "performer");
    WorldObject target =
        TestUtils.createIntelligentWorldObject(3, Constants.ILLUSION_CREATOR_ID, 7);
    target.setProperty(Constants.X, 1);
    target.setProperty(Constants.Y, 1);

    WorldObject realTarget = TestUtils.createIntelligentWorldObject(3, "realTarget");
    realTarget.setProperty(Constants.X, 1);
    realTarget.setProperty(Constants.Y, 1);

    assertEquals(
        realTarget, DefaultGoalObstructedHandler.calculateTarget(performer, target, world));
  }
  @Test
  public void testPerformerAttacksAnimal() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(2, "performer");

    CreatureGenerator creatureGenerator =
        new CreatureGenerator(TestUtils.createIntelligentWorldObject(1, "cow"));
    int cowId = creatureGenerator.generateCow(0, 0, world);
    WorldObject cow = world.findWorldObjectById(cowId);

    assertEquals(false, cow.getProperty(Constants.ANIMAL_ENEMIES).contains(performer));

    DefaultGoalObstructedHandler.performerAttacksAnimal(performer, cow);

    assertEquals(true, cow.getProperty(Constants.ANIMAL_ENEMIES).contains(performer));
  }
  @Test
  public void testHasAnyoneSeenActionNoWitnesses() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.GROUP, new IdList().add(1));
    WorldObject actionTarget = TestUtils.createWorldObject(2, 2, 1, 1, Constants.ID, 2);
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);

    performer.setProperty(Constants.X, 1);
    performer.setProperty(Constants.Y, 1);

    assertEquals(
        false,
        DefaultGoalObstructedHandler.hasAnyoneSeenAction(
            performer, actionTarget, Actions.TALK_ACTION, Args.EMPTY, world));
  }
  @Test
  public void testIsLegalAttackOtherVillager() {
    World world = new WorldImpl(1, 1, null, null);
    WorldObject villagersOrganization = createVillagersOrganization(world);
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(
            2, Constants.GROUP, new IdList().add(villagersOrganization));
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(
            3, Constants.GROUP, new IdList().add(villagersOrganization));
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);

    assertEquals(
        false,
        DefaultGoalObstructedHandler.isLegal(
            performer, actionTarget, Actions.FIRE_BOLT_ATTACK_ACTION, Args.EMPTY, world));
  }
  @Test
  public void testIsLegalAttackTree() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject villagersOrganization = createVillagersOrganization(world);
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(
            2, Constants.GROUP, new IdList().add(villagersOrganization));
    int targetId = PlantGenerator.generateTree(0, 0, world);
    WorldObject actionTarget = world.findWorldObjectById(targetId);
    world.addWorldObject(performer);
    world.addWorldObject(TestUtils.createIntelligentWorldObject(3, "observer"));

    villagersOrganization = createVillagersOrganization(world);

    assertEquals(
        true,
        DefaultGoalObstructedHandler.isLegal(
            performer, actionTarget, Actions.FIRE_BOLT_ATTACK_ACTION, Args.EMPTY, world));
  }
  @Test
  public void testHasAnyoneSeenActionInvisible() {
    World world = new WorldImpl(1, 1, null, null);
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.GROUP, new IdList().add(1));
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList().add(1));
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);

    Conditions.add(performer, Condition.INVISIBLE_CONDITION, 8, world);

    performer.setProperty(Constants.X, 1);
    performer.setProperty(Constants.Y, 1);

    actionTarget.setProperty(Constants.X, 2);
    actionTarget.setProperty(Constants.Y, 2);

    assertEquals(
        false,
        DefaultGoalObstructedHandler.hasAnyoneSeenAction(
            performer, actionTarget, Actions.TALK_ACTION, Args.EMPTY, world));
  }
  @Test
  public void testLogToBackground() {
    World world = new WorldImpl(1, 1, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(1, Constants.GENDER, "male");
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList());
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);

    actionTarget.setProperty(Constants.BACKGROUND, new BackgroundImpl());

    DefaultGoalObstructedHandler.logToBackground(
        Goals.PROTECT_ONE_SELF_GOAL,
        actionTarget,
        actionTarget,
        Actions.MELEE_ATTACK_ACTION,
        Args.EMPTY,
        performer,
        world);
    List<String> angryReasons =
        actionTarget.getProperty(Constants.BACKGROUND).getAngryReasons(true, 2, performer, world);
    assertEquals(1, angryReasons.size());
  }
 @Test
 public void testCalculateBounty() {
   assertEquals(40, DefaultGoalObstructedHandler.calculateBounty(Actions.STEAL_ACTION));
   assertEquals(200, DefaultGoalObstructedHandler.calculateBounty(Actions.MELEE_ATTACK_ACTION));
 }