1 /*
2 * Copyright (C) 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 package nl.tudelft.goal.ut3.environment;
18
19 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
20 import eis.exceptions.PerceiveException;
21 import eis.iilang.Numeral;
22 import eis.iilang.Percept;
23 import java.util.ArrayList;
24 import nl.tudelft.goal.unreal.messages.UnrealIdOrLocation;
25 import org.junit.Test;
26 import static org.junit.Assert.*;
27
28 /**
29 * Tests for almost all the UT3 action percepts.
30 *
31 * @author Evers
32 */
33 public class ActionPerceptTests extends AbstractEnvironmentTests {
34
35 // TODO: Fragged percept is hard to test because we actually need to load two agents in the world and let
36 // on of them finish the other, instead we could spawn the bot with a rocket-launcher and kill himself
37 // Navigation tests are in NavigationTest.java
38
39 /**
40 * Check the path percept.
41 */
42 @Test
43 public void pathTest() throws InterruptedException, PerceiveException {
44 // Calculate path to the udamage pickup
45 nl.tudelft.goal.unreal.messages.Percept p = testBot.path(new UnrealIdOrLocation(testBot.getInfo().getLocation()), new UnrealIdOrLocation(UnrealId.get("UTPickupFactory_UDamage_0")));
46 // We can only test the EndId and the list of locations because start-position are different every time
47 assertTrue(p.size() == 4);
48 assertEquals(UnrealId.get("UTPickupFactory_UDamage_0"), p.get(1));
49 ArrayList<UnrealId> unrealIds = (ArrayList<UnrealId>) p.get(3);
50 assertEquals(UnrealId.get("UTPickupFactory_UDamage_0"), unrealIds.get(unrealIds.size()-1));
51 }
52
53 /**
54 * Check the logic percept.
55 * @throws PerceiveException
56 */
57 @Test
58 public void logicTest() throws PerceiveException {
59 // Check if there has been one logic iteration
60 for(Percept p : startupPercepts) {
61 if(p.getName().equals("logic")) {
62 assertTrue(p.getParameters().size() == 1);
63 assertFalse(new Numeral(0).equals(p.getParameters().get(0)));
64 }
65 }
66 }
67 }