InventoryViewModel extends BaseStockMovementViewModel { public StockOnHandStatus getStockOnHandLevel() { if (stockOnHand == 0) { return StockOnHandStatus.STOCK_OUT; } if (stockCard.getCMM() < 0) { return StockOnHandStatus.REGULAR_STOCK; } if (stockCard.isLowStock()) { return StockOnHandStatus.LOW_STOCK; } else if (stockCard.isOverStock()) { return StockOnHandStatus.OVER_STOCK; } return StockOnHandStatus.REGULAR_STOCK; } InventoryViewModel(StockCard stockCard);  InventoryViewModel(Product product); SpannableStringBuilder getStyledName(); SpannableStringBuilder getStyleType(); SpannableStringBuilder getStyledUnit(); boolean validate(); static InventoryViewModel buildEmergencyModel(StockCard stockCard); StockOnHandStatus getStockOnHandLevel(); Long getLotListQuantityTotalAmount(); String getFormattedProductName(); String getFormattedProductUnit(); @Override boolean equals(Object object); @Override int hashCode(); @Override String toString();  }
@Test public void shouldGetNormalLevelWhenSOHGreaterThanAvg() throws LMISException { StockCard stockCard = new StockCard(); Product product = new Product(); stockCard.setProduct(product); stockCard.setStockOnHand(100); stockCard.setAvgMonthlyConsumption(80); viewModel.setStockCard(stockCard); viewModel.setStockOnHand(100); StockCardViewHolder.StockOnHandStatus stockOnHandLevel = viewModel.getStockOnHandLevel(); Assertions.assertThat(stockOnHandLevel).isEqualTo(StockCardViewHolder.StockOnHandStatus.REGULAR_STOCK); }
@Test public void shouldGetNormalLevelWhenAvgMonthlyConsumptionLessThanZero() throws LMISException { StockCard stockCard = new StockCard(); Product product = new Product(); stockCard.setProduct(product); stockCard.setAvgMonthlyConsumption(-1); viewModel.setStockCard(stockCard); viewModel.setStockOnHand(100); StockCardViewHolder.StockOnHandStatus stockOnHandLevel = viewModel.getStockOnHandLevel(); Assertions.assertThat(stockOnHandLevel).isEqualTo(StockCardViewHolder.StockOnHandStatus.REGULAR_STOCK); }
@Test public void shouldGetOverLevelWhenSOHSmallerThanAvg() throws LMISException { StockCard stockCard = new StockCard(); Product product = new Product(); stockCard.setProduct(product); stockCard.setStockOnHand(30); stockCard.setAvgMonthlyConsumption(10); viewModel.setStockCard(stockCard); viewModel.setStockOnHand(30); StockCardViewHolder.StockOnHandStatus stockOnHandLevel = viewModel.getStockOnHandLevel(); Assertions.assertThat(stockOnHandLevel).isEqualTo(StockCardViewHolder.StockOnHandStatus.OVER_STOCK); }
@Test public void shouldGetLowLevelWhenSOHSmallerThanAvg() throws LMISException { StockCard stockCard = new StockCard(); Product product = new Product(); stockCard.setProduct(product); stockCard.setStockOnHand(2); stockCard.setAvgMonthlyConsumption(100); viewModel.setStockCard(stockCard); viewModel.setStockOnHand(2); StockCardViewHolder.StockOnHandStatus stockOnHandLevel = viewModel.getStockOnHandLevel(); Assertions.assertThat(stockOnHandLevel).isEqualTo(StockCardViewHolder.StockOnHandStatus.LOW_STOCK); }
@Test public void shouldGetStockOutLevelWhenSOHIsZero() throws LMISException { StockCard stockCard = new StockCard(); Product product = new Product(); stockCard.setProduct(product); stockCard.setAvgMonthlyConsumption(80); viewModel.setStockCard(stockCard); viewModel.setStockOnHand(0); StockCardViewHolder.StockOnHandStatus stockOnHandLevel = viewModel.getStockOnHandLevel(); Assertions.assertThat(stockOnHandLevel).isEqualTo(StockCardViewHolder.StockOnHandStatus.STOCK_OUT); }
@Test public void shouldGetStockOutLevelWhenSOHIsZeroEvenAvgMonthlyConsumptionLessThanZero() throws LMISException { StockCard stockCard = new StockCard(); Product product = new Product(); stockCard.setProduct(product); stockCard.setAvgMonthlyConsumption(-1); viewModel.setStockCard(stockCard); viewModel.setStockOnHand(0); StockCardViewHolder.StockOnHandStatus stockOnHandLevel = viewModel.getStockOnHandLevel(); Assertions.assertThat(stockOnHandLevel).isEqualTo(StockCardViewHolder.StockOnHandStatus.STOCK_OUT); }