### Question:
Adjustment implements Serializable, Snapshotable { public int getNewStockOnHand() { int stock = commodity.getStockOnHand(); if (positive) { return stock + quantity; } return stock - quantity; } Adjustment();  Adjustment(Commodity commodity, int quantityEntered,
                      boolean positive, String reason);  Adjustment(Commodity commodity, int quantityEntered, int quantityAllocated,
                      boolean positive, String reason); Commodity getCommodity(); @Override List<CommoditySnapshotValue> getActivitiesValues(); @Override Date getDate(); int getQuantity(); long getId(); boolean isPositive(); String getReason(); String getType(); int getNewStockOnHand(); Date getCreated(); void setCreated(Date created); int getAllocated(); void setAllocated(int allocated);  }### Answer:
@Test public void shouldAddToStockOnHandIfPositive() { Commodity commodity = mock(Commodity.class); when(commodity.getStockOnHand()).thenReturn(10); Adjustment adjustment = new Adjustment(commodity, 20, true, "Count"); assertThat(adjustment.getNewStockOnHand(), is(30)); }
@Test public void shouldSubtractFromStockOnHandIfNegative() { Commodity commodity = mock(Commodity.class); when(commodity.getStockOnHand()).thenReturn(20); Adjustment adjustment = new Adjustment(commodity, 10, false, "Count"); assertThat(adjustment.getNewStockOnHand(), is(10)); }