mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 16:49:11 +00:00
Merge pull request #171 from ryleykimmel/consistent-tests
Make test class and method names consistent
This commit is contained in:
+2
-2
@@ -15,13 +15,13 @@ import static org.powermock.api.mockito.PowerMockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Player.class})
|
||||
public class ChatMessageHandlerTest {
|
||||
public final class ChatMessageHandlerTests {
|
||||
|
||||
private final World world = new World();
|
||||
private final ChatMessageHandler chatMessageHandler = new ChatMessageHandler(world);
|
||||
|
||||
@Test
|
||||
public void testTerminatedIfMuted() throws Exception {
|
||||
public void terminateIfMuted() throws Exception {
|
||||
Player player = PowerMockito.mock(Player.class);
|
||||
|
||||
when(player.isMuted()).thenReturn(true);
|
||||
+4
-4
@@ -19,11 +19,11 @@ import static org.powermock.api.mockito.PowerMockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Player.class, ItemDefinition.class})
|
||||
public class ItemOnItemVerificationHandlerTest {
|
||||
public final class ItemOnItemVerificationHandlerTests {
|
||||
|
||||
private World world = new World();
|
||||
private final World world = new World();
|
||||
|
||||
private ItemOnItemVerificationHandler itemOnItemVerificationHandler = new ItemOnItemVerificationHandler(world);
|
||||
private final ItemOnItemVerificationHandler itemOnItemVerificationHandler = new ItemOnItemVerificationHandler(world);
|
||||
|
||||
@Before
|
||||
public void setupTestItemDefinitions() {
|
||||
@@ -32,7 +32,7 @@ public class ItemOnItemVerificationHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerminateWithNoTargetItem() throws Exception {
|
||||
public void terminateWithNoTargetItem() throws Exception {
|
||||
Player player = mock(Player.class);
|
||||
Inventory inventory = new Inventory(28);
|
||||
inventory.set(1, new Item(4151, 1));
|
||||
+4
-4
@@ -30,7 +30,7 @@ import static org.powermock.api.mockito.PowerMockito.*;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Player.class, World.class, Region.class, RegionRepository.class, ObjectDefinition.class,
|
||||
ItemDefinition.class})
|
||||
public class ItemOnObjectVerificationHandlerTest {
|
||||
public final class ItemOnObjectVerificationHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setupTestItemDefinitions() {
|
||||
@@ -43,7 +43,7 @@ public class ItemOnObjectVerificationHandlerTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testTerminateIfInvalidItem() throws Exception {
|
||||
public void terminateIfInvalidItem() throws Exception {
|
||||
Position playerPosition = new Position(3200, 3200);
|
||||
Position objectPosition = new Position(3200, 3216);
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ItemOnObjectVerificationHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerminateIfInvalidSlot() throws Exception {
|
||||
public void terminateIfInvalidSlot() throws Exception {
|
||||
Position playerPosition = new Position(3200, 3200);
|
||||
Position objectPosition = new Position(3200, 3200);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ItemOnObjectVerificationHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerminateIfObjectOutOfRange() throws Exception {
|
||||
public void terminateIfObjectOutOfRange() throws Exception {
|
||||
Position playerPosition = new Position(3200, 3200);
|
||||
Position objectPosition = new Position(3200, 3200);
|
||||
|
||||
+3
-4
@@ -28,7 +28,7 @@ import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({World.class, Player.class, ObjectDefinition.class, RegionRepository.class, Region.class})
|
||||
public class ObjectActionVerificationHandlerTest {
|
||||
public final class ObjectActionVerificationHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setupTestObjectDefinitions() {
|
||||
@@ -37,7 +37,7 @@ public class ObjectActionVerificationHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTerminateIfOutOfRange() throws Exception {
|
||||
public void terminateIfOutOfRange() throws Exception {
|
||||
Position playerPosition = new Position(3200, 3200);
|
||||
Position objectPosition = new Position(3200, 3216);
|
||||
|
||||
@@ -64,8 +64,7 @@ public class ObjectActionVerificationHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
public void testTerminateIfNoObject() throws Exception {
|
||||
public void terminateIfNoObject() throws Exception {
|
||||
Position playerPosition = new Position(3200, 3200);
|
||||
Position objectPosition = new Position(3200, 3201);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.apollo.game.model;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests the {@link Position} class.
|
||||
*/
|
||||
public final class PositionTests {
|
||||
|
||||
/**
|
||||
* Tests the {@link Position#getHeight()} method.
|
||||
*/
|
||||
@Test
|
||||
public void getHeight() {
|
||||
Position position = new Position(3222, 3222, 3);
|
||||
Assert.assertEquals(3, position.getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the creation of an invalid {@link Position}.
|
||||
*/
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void createNegativePosition() {
|
||||
new Position(3222, 3222, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the creation of an invalid {@link Position}.
|
||||
*/
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void createOutOfBoundsPosition() {
|
||||
new Position(3222, 3222, 4);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package org.apollo.game.model;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests the {@link Position} class.
|
||||
*
|
||||
* @author Ryley
|
||||
*/
|
||||
public final class TestPosition {
|
||||
|
||||
/**
|
||||
* Tests the {@link Position#getHeight()} method.
|
||||
*/
|
||||
@Test
|
||||
public void testGetHeight() {
|
||||
Position position = new Position(3222, 3222, 3);
|
||||
Assert.assertEquals(3, position.getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the creation of an invalid {@link Position}.
|
||||
*/
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void testCreateNegativePosition() {
|
||||
new Position(3222, 3222, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the creation of an invalid {@link Position}.
|
||||
*/
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void testCreateOutOfBoundsPosition() {
|
||||
new Position(3222, 3222, 4);
|
||||
}
|
||||
|
||||
}
|
||||
+11
-11
@@ -21,7 +21,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(Player.class)
|
||||
public final class MobRepositoryTest {
|
||||
public final class MobRepositoryTests {
|
||||
|
||||
/**
|
||||
* The capacity of the MobRepository.
|
||||
@@ -32,7 +32,7 @@ public final class MobRepositoryTest {
|
||||
* Tests {@link MobRepository#capacity()}.
|
||||
*/
|
||||
@Test
|
||||
public void testCapacity() {
|
||||
public void capacity() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
assertEquals(CAPACITY, players.capacity());
|
||||
@@ -42,7 +42,7 @@ public final class MobRepositoryTest {
|
||||
* Tests {@link MobRepository#add(Mob)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAdd() {
|
||||
public void add() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
Player player = mock(Player.class);
|
||||
@@ -58,7 +58,7 @@ public final class MobRepositoryTest {
|
||||
* Tests {@link MobRepository#remove(Mob)}.
|
||||
*/
|
||||
@Test
|
||||
public void testRemove() {
|
||||
public void remove() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
Player player = mock(Player.class);
|
||||
@@ -77,7 +77,7 @@ public final class MobRepositoryTest {
|
||||
* Tests failing of {@link MobRepository#remove(Mob)}
|
||||
*/
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testRemoveNull() {
|
||||
public void removeNull() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
players.remove(null);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public final class MobRepositoryTest {
|
||||
* Ensures that a MobRepository maintains a fixed capacity.
|
||||
*/
|
||||
@Test
|
||||
public void testCapacityExceeded() {
|
||||
public void capacityExceeded() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
for (int index = 0; index < CAPACITY; index++) {
|
||||
@@ -107,7 +107,7 @@ public final class MobRepositoryTest {
|
||||
* Tests {@link Iterator#hasNext()} for a MobRepository.
|
||||
*/
|
||||
@Test
|
||||
public void testIteratorHasNext() {
|
||||
public void iteratorHasNext() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
Player player = mock(Player.class);
|
||||
@@ -123,7 +123,7 @@ public final class MobRepositoryTest {
|
||||
* Tests {@link Iterator#next()} for a MobRepository.
|
||||
*/
|
||||
@Test
|
||||
public void testIteratorNext() {
|
||||
public void iteratorNext() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
Player first = mock(Player.class);
|
||||
@@ -148,7 +148,7 @@ public final class MobRepositoryTest {
|
||||
* Tests {@link Iterator#remove()} for a MobRepository.
|
||||
*/
|
||||
@Test
|
||||
public void testIteratorRemove() {
|
||||
public void iteratorRemove() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
Player first = mock(Player.class);
|
||||
@@ -175,7 +175,7 @@ public final class MobRepositoryTest {
|
||||
* {@link NoSuchElementException} if the iterator contains no more elements.
|
||||
*/
|
||||
@Test(expected = NoSuchElementException.class)
|
||||
public void testIteratorNextOverflow() {
|
||||
public void iteratorNextOverflow() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
Player first = mock(Player.class);
|
||||
@@ -201,7 +201,7 @@ public final class MobRepositoryTest {
|
||||
* next().
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testIteratorRemoveIllegalState() {
|
||||
public void iteratorRemoveIllegalState() {
|
||||
MobRepository<Player> players = new MobRepository<>(CAPACITY);
|
||||
|
||||
Player player = mock(Player.class);
|
||||
+2
-2
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertEquals;
|
||||
*
|
||||
* @author Graham
|
||||
*/
|
||||
public class TestGamePacketEncoder {
|
||||
public class GamePacketEncoderTests {
|
||||
|
||||
/**
|
||||
* Tests the {@link GamePacketEncoder#encode} method.
|
||||
@@ -21,7 +21,7 @@ public class TestGamePacketEncoder {
|
||||
* @throws Exception If an error occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testEncode() throws Exception {
|
||||
public void encode() throws Exception {
|
||||
// generates 243, 141, 34, -223, 121...
|
||||
IsaacRandom random = new IsaacRandom(new int[] { 0, 0, 0, 0 });
|
||||
GamePacketEncoder encoder = new GamePacketEncoder(random);
|
||||
@@ -29,7 +29,7 @@ public final class XmlParserTests {
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParseInputStream() throws SAXException, IOException {
|
||||
public void parseInputStream() throws SAXException, IOException {
|
||||
XmlParser parser = new XmlParser();
|
||||
InputStream input = new ByteArrayInputStream("<root a='1' b='2' c='3'><z><y><x></x></y></z></root>".getBytes());
|
||||
XmlNode root = parser.parse(input);
|
||||
@@ -76,7 +76,7 @@ public final class XmlParserTests {
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
@Test
|
||||
public void testParseReader() throws SAXException, IOException {
|
||||
public void parseReader() throws SAXException, IOException {
|
||||
XmlParser parser = new XmlParser();
|
||||
Reader reader = new StringReader("<alphabet><a>1</a><b>2</b><c>3</c></alphabet>");
|
||||
XmlNode root = parser.parse(reader);
|
||||
|
||||
Reference in New Issue
Block a user