GroundItemsPlugin extends Plugin { private void notifyHighlightedItem(GroundItem item) { final boolean shouldNotifyHighlighted = config.notifyHighlightedDrops() && TRUE.equals(highlightedItems.getUnchecked(new NamedQuantity(item))); final boolean shouldNotifyTier = config.notifyTier() != HighlightTier.OFF && getValueByMode(item.getGePrice(), item.getHaPrice()) > config.notifyTier().getValueFromTier(config) && FALSE.equals(hiddenItems.getUnchecked(new NamedQuantity(item))); final String dropType; if (shouldNotifyHighlighted) { dropType = "highlighted"; } else if (shouldNotifyTier) { dropType = "valuable"; } else { return; } final Player local = client.getLocalPlayer(); final StringBuilder notificationStringBuilder = new StringBuilder() .append("[") .append(local.getName()) .append("] received a ") .append(dropType) .append(" drop: ") .append(item.getName()); if (item.getQuantity() > 1) { if (item.getQuantity() >= MAX_QUANTITY) { notificationStringBuilder.append(" (Lots!)"); } else { notificationStringBuilder.append(" (") .append(QuantityFormatter.quantityToStackSize(item.getQuantity())) .append(")"); } } notifier.notify(notificationStringBuilder.toString()); }  @Subscribe void onConfigChanged(ConfigChanged event); @Subscribe void onGameStateChanged(final GameStateChanged event); @Subscribe void onItemSpawned(ItemSpawned itemSpawned); @Subscribe void onItemDespawned(ItemDespawned itemDespawned); @Subscribe void onItemQuantityChanged(ItemQuantityChanged itemQuantityChanged); @Subscribe void onNpcLootReceived(NpcLootReceived npcLootReceived); @Subscribe void onPlayerLootReceived(PlayerLootReceived playerLootReceived); @Subscribe void onClientTick(ClientTick event); @Subscribe void onMenuEntryAdded(MenuEntryAdded event); @Subscribe void onFocusChanged(FocusChanged focusChanged); @Subscribe void onMenuOptionClicked(MenuOptionClicked menuOptionClicked);  }
@Test public void testNotifyHighlightedItem() { when(config.getHighlightItems()).thenReturn("abyssal whip"); when(config.notifyTier()).thenReturn(HighlightTier.OFF); when(config.notifyHighlightedDrops()).thenReturn(true); when(itemManager.getItemComposition(ItemID.ABYSSAL_WHIP)).thenAnswer(a -> { ItemComposition itemComposition = mock(ItemComposition.class); when(itemComposition.getName()).thenReturn("Abyssal whip"); return itemComposition; }); ConfigChanged configChanged = new ConfigChanged(); configChanged.setGroup("grounditems"); groundItemsPlugin.onConfigChanged(configChanged); Tile tile = mock(Tile.class); when(tile.getItemLayer()).thenReturn(mock(ItemLayer.class)); when(tile.getWorldLocation()).thenReturn(new WorldPoint(0, 0, 0)); TileItem tileItem = mock(TileItem.class); when(tileItem.getId()).thenReturn(ItemID.ABYSSAL_WHIP); when(tileItem.getQuantity()).thenReturn(1); groundItemsPlugin.onItemSpawned(new ItemSpawned(tile, tileItem)); verify(notifier).notify("[Adam] received a highlighted drop: Abyssal whip"); }