bank value: use ItemContainer instead of WidgetItemQuery

This commit is contained in:
trimbe
2019-01-04 22:03:10 -05:00
committed by Adam
parent ecd0f7dce3
commit 60aa135fe5
3 changed files with 100 additions and 36 deletions

View File

@@ -30,7 +30,10 @@ import com.google.inject.testing.fieldbinder.Bind;
import com.google.inject.testing.fieldbinder.BoundFieldModule;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemComposition;
import net.runelite.api.ItemContainer;
import net.runelite.api.ItemID;
import net.runelite.api.queries.BankItemQuery;
import net.runelite.api.widgets.WidgetItem;
@@ -53,10 +56,6 @@ public class BankCalculationTest
@Bind
private Client client;
@Mock
@Bind
private QueryRunner queryRunner;
@Mock
@Bind
private ItemManager itemManager;
@@ -80,21 +79,37 @@ public class BankCalculationTest
when(bankValueConfig.showHA())
.thenReturn(true);
WidgetItem[] widgetItems = ImmutableList.of(
new WidgetItem(ItemID.COINS_995, Integer.MAX_VALUE, -1, null),
new WidgetItem(ItemID.ABYSSAL_WHIP, 1_000_000_000, -1, null)
).toArray(new WidgetItem[0]);
Item coins = mock(Item.class);
when(coins.getId())
.thenReturn(ItemID.COINS_995);
when(coins.getQuantity())
.thenReturn(Integer.MAX_VALUE);
when(queryRunner.runQuery(any(BankItemQuery.class)))
.thenReturn(widgetItems);
ItemComposition whip = mock(ItemComposition.class);
Item whip = mock(Item.class);
when(whip.getId())
.thenReturn(ItemID.ABYSSAL_WHIP);
when(whip.getPrice())
when(whip.getQuantity())
.thenReturn(1_000_000_000);
Item[] items = ImmutableList.of(
coins,
whip
).toArray(new Item[0]);
ItemContainer bankContainer = mock(ItemContainer.class);
when(bankContainer.getItems())
.thenReturn(items);
when(client.getItemContainer(InventoryID.BANK))
.thenReturn(bankContainer);
ItemComposition whipComp = mock(ItemComposition.class);
when(whipComp.getId())
.thenReturn(ItemID.ABYSSAL_WHIP);
when(whipComp.getPrice())
.thenReturn(7); // 7 * .6 = 4, 4 * 1m overflows
when(itemManager.getItemComposition(ItemID.ABYSSAL_WHIP))
.thenReturn(whip);
.thenReturn(whipComp);
bankCalculation.calculate();