client: Add back item tests (#1160)

* Fix upstream merge

* mixins: Fix checkstyle

* client: Add back item tests

* discord: builder default
This commit is contained in:
Owain van Brakel
2019-07-28 00:45:27 +02:00
committed by Kyleeld
parent 6ab7640266
commit 75ef43cc0e
6 changed files with 26 additions and 69 deletions

View File

@@ -48,6 +48,7 @@ public class DiscordMessage
String avatarUrl; String avatarUrl;
@SerializedName("tts") @SerializedName("tts")
boolean textToSpeech; boolean textToSpeech;
@Builder.Default
List<DiscordEmbed> embeds = new ArrayList<>(); List<DiscordEmbed> embeds = new ArrayList<>();
public DiscordMessage() public DiscordMessage()

View File

@@ -37,7 +37,6 @@ import net.runelite.client.game.ItemManager;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
@@ -65,21 +64,12 @@ public class ContainerCalculationTest
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
} }
@Ignore
@Test @Test
public void testCalculate() public void testCalculate()
{ {
Item coins = mock(Item.class); Item coins = new Item(ItemID.COINS_995, Integer.MAX_VALUE);
when(coins.getId())
.thenReturn(ItemID.COINS_995);
when(coins.getQuantity())
.thenReturn(Integer.MAX_VALUE);
Item whip = mock(Item.class); Item whip = new Item(ItemID.ABYSSAL_WHIP, 1_000_000_000);
when(whip.getId())
.thenReturn(ItemID.ABYSSAL_WHIP);
when(whip.getQuantity())
.thenReturn(1_000_000_000);
Item[] items = ImmutableList.of( Item[] items = ImmutableList.of(
coins, coins,

View File

@@ -41,7 +41,6 @@ import net.runelite.client.Notifier;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
@@ -98,7 +97,6 @@ public class ItemChargePluginTest
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
} }
@Ignore
@Test @Test
public void testOnChatMessage() public void testOnChatMessage()
{ {
@@ -137,8 +135,7 @@ public class ItemChargePluginTest
when(client.getItemContainer(eq(InventoryID.EQUIPMENT))).thenReturn(equipmentItemContainer); when(client.getItemContainer(eq(InventoryID.EQUIPMENT))).thenReturn(equipmentItemContainer);
Item[] items = new Item[EquipmentInventorySlot.RING.getSlotIdx() + 1]; Item[] items = new Item[EquipmentInventorySlot.RING.getSlotIdx() + 1];
when(equipmentItemContainer.getItems()).thenReturn(items); when(equipmentItemContainer.getItems()).thenReturn(items);
Item ring = mock(Item.class); Item ring = new Item(ItemID.RING_OF_FORGING, 1);
when(ring.getId()).thenReturn(ItemID.RING_OF_FORGING);
items[EquipmentInventorySlot.RING.getSlotIdx()] = ring; items[EquipmentInventorySlot.RING.getSlotIdx()] = ring;
// Run message // Run message
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0); chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0);

View File

@@ -90,21 +90,15 @@ public class ItemsKeptOnDeathPluginTest
when(itemManager.canonicalize(id)).thenReturn(id); when(itemManager.canonicalize(id)).thenReturn(id);
when(itemManager.getItemPrice(id, true)).thenReturn(price); when(itemManager.getItemPrice(id, true)).thenReturn(price);
return mockItem(id, qty); return item(id, qty);
} }
// Creates a mocked item // Creates a new item
private Item mockItem(final int id, final int qty) private static Item item(final int id, final int qty)
{ {
Item item = mock(Item.class); return new Item(id, qty);
// when(item.getId()).thenReturn(id);
// when(item.getQuantity()).thenReturn(qty);
return item;
} }
@Ignore
@Test @Test
public void deathPriceTestRegularItems() public void deathPriceTestRegularItems()
{ {
@@ -118,7 +112,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals(35000, plugin.getDeathPrice(defender)); assertEquals(35000, plugin.getDeathPrice(defender));
} }
@Ignore
@Test @Test
public void deathPriceTestItemMapping() public void deathPriceTestItemMapping()
{ {
@@ -134,7 +127,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals(1000000, plugin.getDeathPrice(slayerHelm)); assertEquals(1000000, plugin.getDeathPrice(slayerHelm));
} }
@Ignore
@Test @Test
public void deathPriceTestFixedPriceItems() public void deathPriceTestFixedPriceItems()
{ {
@@ -159,7 +151,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals(13500 + braceletOffset, plugin.getDeathPrice(brace)); assertEquals(13500 + braceletOffset, plugin.getDeathPrice(brace));
} }
@Ignore
@Test @Test
public void deathPriceTestDynamicPriceItems() public void deathPriceTestDynamicPriceItems()
{ {
@@ -193,7 +184,6 @@ public class ItemsKeptOnDeathPluginTest
}; };
} }
@Ignore
@Test @Test
public void alwaysLostTestRunePouch() public void alwaysLostTestRunePouch()
{ {
@@ -207,7 +197,6 @@ public class ItemsKeptOnDeathPluginTest
assertFalse(deathItems.isHasAlwaysLost()); assertFalse(deathItems.isHasAlwaysLost());
} }
@Ignore
@Test @Test
public void alwaysLostTestRunePouchWildy() public void alwaysLostTestRunePouchWildy()
{ {
@@ -222,7 +211,6 @@ public class ItemsKeptOnDeathPluginTest
assertTrue(deathItems.isHasAlwaysLost()); assertTrue(deathItems.isHasAlwaysLost());
} }
@Ignore
@Test @Test
public void alwaysLostTestLootBag() public void alwaysLostTestLootBag()
{ {
@@ -237,7 +225,6 @@ public class ItemsKeptOnDeathPluginTest
} }
@Ignore
@Test @Test
public void alwaysLostTestLootBagWildy() public void alwaysLostTestLootBagWildy()
{ {
@@ -296,7 +283,6 @@ public class ItemsKeptOnDeathPluginTest
assertFalse(plugin.isClueBoxable(ItemID.SPADE)); assertFalse(plugin.isClueBoxable(ItemID.SPADE));
} }
@Ignore
@Test @Test
public void clueBoxTestDefault() public void clueBoxTestDefault()
{ {
@@ -321,7 +307,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals((inv.length + equip.length) - expectedKept.size(), lost.size()); assertEquals((inv.length + equip.length) - expectedKept.size(), lost.size());
} }
@Ignore
@Test @Test
public void clueBoxTestDeepWildy() public void clueBoxTestDeepWildy()
{ {
@@ -346,7 +331,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals((inv.length + equip.length) - keptOffset, lost.size()); assertEquals((inv.length + equip.length) - keptOffset, lost.size());
} }
@Ignore
@Test @Test
public void clueBoxTestDeepWildyProtectItem() public void clueBoxTestDeepWildyProtectItem()
{ {
@@ -373,7 +357,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals((inv.length + equip.length) - keptOffset, lost.size()); assertEquals((inv.length + equip.length) - keptOffset, lost.size());
} }
@Ignore
@Test @Test
public void clueBoxTestDeepWildySkulled() public void clueBoxTestDeepWildySkulled()
{ {
@@ -396,7 +379,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals(lost.size(), (inv.length + equip.length) - keptOffset); assertEquals(lost.size(), (inv.length + equip.length) - keptOffset);
} }
@Ignore
@Test @Test
public void clueBoxTestLowWildy() public void clueBoxTestLowWildy()
{ {
@@ -422,7 +404,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals(lost.size(), (inv.length + equip.length) - keptOffset); assertEquals(lost.size(), (inv.length + equip.length) - keptOffset);
} }
@Ignore
@Test @Test
public void clueBoxTestLowWildyProtectItem() public void clueBoxTestLowWildyProtectItem()
{ {
@@ -450,7 +431,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals((inv.length + equip.length) - keptOffset, lost.size()); assertEquals((inv.length + equip.length) - keptOffset, lost.size());
} }
@Ignore
@Test @Test
public void clueBoxTestLowWildySkulled() public void clueBoxTestLowWildySkulled()
{ {
@@ -499,7 +479,6 @@ public class ItemsKeptOnDeathPluginTest
}; };
} }
@Ignore
@Test @Test
public void clueBoxTestCasketProtect() public void clueBoxTestCasketProtect()
{ {
@@ -537,7 +516,6 @@ public class ItemsKeptOnDeathPluginTest
}; };
} }
@Ignore
@Test @Test
public void gracefulValueTest() public void gracefulValueTest()
{ {
@@ -566,7 +544,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals((inv.length + equip.length) - expectedKept.size(), lost.size()); assertEquals((inv.length + equip.length) - expectedKept.size(), lost.size());
} }
@Ignore
@Test @Test
public void gracefulValueTestWildy() public void gracefulValueTestWildy()
{ {
@@ -592,7 +569,6 @@ public class ItemsKeptOnDeathPluginTest
assertEquals((inv.length + equip.length) - expectedKept.size(), lost.size()); assertEquals((inv.length + equip.length) - expectedKept.size(), lost.size());
} }
@Ignore
@Test @Test
public void lostIfNotProtectedTestLost() public void lostIfNotProtectedTestLost()
{ {
@@ -608,7 +584,6 @@ public class ItemsKeptOnDeathPluginTest
assertTrue(lost.contains(new ItemStack(ItemID.SHADOW_SWORD, 1))); assertTrue(lost.contains(new ItemStack(ItemID.SHADOW_SWORD, 1)));
} }
@Ignore
@Test @Test
public void lostIfNotProtectedTestKept() public void lostIfNotProtectedTestKept()
{ {

View File

@@ -52,7 +52,6 @@ public class MaxHitCalculatorTest
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
} }
@Ignore
@Test @Test
public void calculate() public void calculate()
{ {

View File

@@ -112,7 +112,6 @@ public class MotherlodePluginTest
when(client.getMapRegions()).thenReturn(new int[]{14679}); when(client.getMapRegions()).thenReturn(new int[]{14679});
} }
@Ignore
@Test @Test
public void testOreCounter() public void testOreCounter()
{ {
@@ -128,12 +127,12 @@ public class MotherlodePluginTest
// Create before inventory // Create before inventory
ItemContainer inventory = mock(ItemContainer.class); ItemContainer inventory = mock(ItemContainer.class);
Item[] items = new Item[]{ Item[] items = new Item[]{
mockItem(ItemID.RUNITE_ORE, 1), item(ItemID.RUNITE_ORE, 1),
mockItem(ItemID.GOLDEN_NUGGET, 4), item(ItemID.GOLDEN_NUGGET, 4),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
}; };
when(inventory.getItems()) when(inventory.getItems())
@@ -147,17 +146,16 @@ public class MotherlodePluginTest
inventory = mock(ItemContainer.class); inventory = mock(ItemContainer.class);
// +1 rune, +4 nugget, +2 coal, +1 addy // +1 rune, +4 nugget, +2 coal, +1 addy
items = new Item[]{ items = new Item[]{
mockItem(ItemID.RUNITE_ORE, 1), item(ItemID.RUNITE_ORE, 1),
mockItem(ItemID.RUNITE_ORE, 1), item(ItemID.RUNITE_ORE, 1),
mockItem(ItemID.GOLDEN_NUGGET, 8), item(ItemID.GOLDEN_NUGGET, 8),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.COAL, 1), item(ItemID.COAL, 1),
mockItem(ItemID.ADAMANTITE_ORE, 1), item(ItemID.ADAMANTITE_ORE, 1),
}; };
when(inventory.getItems()) when(inventory.getItems())
.thenReturn(items); .thenReturn(items);
@@ -173,11 +171,8 @@ public class MotherlodePluginTest
verifyNoMoreInteractions(motherlodeSession); verifyNoMoreInteractions(motherlodeSession);
} }
private static Item mockItem(int itemId, int quantity) private static Item item(int itemId, int quantity)
{ {
Item item = mock(Item.class); return new Item(itemId, quantity);
when(item.getId()).thenReturn(itemId);
when(item.getQuantity()).thenReturn(quantity);
return item;
} }
} }