@Test public void shouldSaveCommodityActionWithDataSet() throws Exception { commodityService.initialise(new User("test", "pass")); Commodity testCommodity = commodityService.all().get(0); assertThat(testCommodity.getCommodityActionsSaved().size(), is(not(0))); CommodityAction actual = (CommodityAction) testCommodity.getCommodityActionsSaved().toArray()[0]; assertThat(actual.getCommodityActionDataSets(), is(notNullValue())); }
@Test public void shouldReloadMostDispensedCommodities() throws Exception { commodityService.initialise(new User("test", "pass")); categoryService.clearCache(); List<Commodity> mostConsumed = commodityService.getMost5HighlyDispensedCommodities(); Commodity commodity = mostConsumed.get(0); String previousMostDispensedCommodity = commodity.getName(); dispense(commodity, 20, dispensingService); commodity = commodityService.getMost5HighlyDispensedCommodities().get(0); assertThat(commodity.getName(), is(previousMostDispensedCommodity)); }
@Test public void shouldReturnClosingBalanceUtilizationItemWithCorrectUtilizationValue() throws Exception { commodityService.initialise(new User("test", "pass")); categoryService.clearCache(); Commodity commodity = categoryService.all().get(0).getCommodities().get(0); Calendar calendar = Calendar.getInstance(); Date today = calendar.getTime(); int stockOnHand = commodity.getStockOnHand(); dispense(commodity, 3, dispensingService); List<UtilizationItem> utilizationItems = commodityService.getMonthlyUtilizationItems(commodity, today); int expectedClosingStock = stockOnHand - 3; int utilizationValueIndex = DateUtil.dayNumber(today) - 1; assertThat( utilizationItems.get(4).getUtilizationValues().get(utilizationValueIndex).getValue(), is(expectedClosingStock)); }
@Test public void shouldSaveCommodityCommodityActivities() { commodityService.initialise(new User("test", "pass")); Commodity testCommodity = commodityService.all().get(0); assertThat(testCommodity.getCommodityActionsSaved().size(), is(not(0))); }