@Test public void testUrgencyFull() throws NoSuchFieldException, IllegalAccessException { // we are going to check that prices change when urgency change // the only stub is the market Market market = mock(Market.class); when(market.getLastPrice()).thenReturn(50); // so last price is 50 model.schedule = mock( Schedule .class); // we also mock the schedule to avoid the inventory control from spamming // buy orders in the schedule when(market.getGoodType()).thenReturn(UndifferentiatedGoodType.GENERIC); Firm f = new Firm(model); PurchasesDepartment dept = PurchasesDepartment.getPurchasesDepartment( 100, f, market, FixedInventoryControl.class, UrgentPriceFollowerStrategy.class, null, null) .getDepartment(); // when there is nobody to search just go at random. Field field = PurchasesDepartment.class.getDeclaredField("pricingStrategy"); field.setAccessible(true); BidPricingStrategy pricing = (BidPricingStrategy) field.get(dept); // assuming the fixed inventory control wants 6 // right now it's danger for (int i = 0; i < 10; i++) assertEquals(pricing.maxPrice(UndifferentiatedGoodType.GENERIC), 60); // barely for (int i = 0; i < 3; i++) f.receive(Good.getInstanceOfUndifferentiatedGood(UndifferentiatedGoodType.GENERIC), null); for (int i = 0; i < 10; i++) assertEquals(pricing.maxPrice(UndifferentiatedGoodType.GENERIC), 50); // acceptable for (int i = 0; i < 3; i++) f.receive(Good.getInstanceOfUndifferentiatedGood(UndifferentiatedGoodType.GENERIC), null); for (int i = 0; i < 10; i++) assertEquals(pricing.maxPrice(UndifferentiatedGoodType.GENERIC), 40); // too much for (int i = 0; i < 30; i++) f.receive(Good.getInstanceOfUndifferentiatedGood(UndifferentiatedGoodType.GENERIC), null); for (int i = 0; i < 10; i++) assertEquals(pricing.maxPrice(UndifferentiatedGoodType.GENERIC), 25); }