### Question:
MinimumGasPriceCalculator { public Coin calculate(Coin previousMGP, Coin targetMGP) { BlockGasPriceRange priceRange = new BlockGasPriceRange(previousMGP); if (priceRange.inRange(targetMGP)) { return targetMGP; } if (previousMGP.compareTo(targetMGP) < 0) { return priceRange.getUpperLimit(); } return priceRange.getLowerLimit(); }  Coin calculate(Coin previousMGP, Coin targetMGP);  }### Answer:
@Test public void increaseMgp() { MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator(); Coin prev = Coin.valueOf(1000L); Coin target = Coin.valueOf(2000L); Coin mgp = mgpCalculator.calculate(prev, target); Assert.assertEquals(Coin.valueOf(1010), mgp); }
@Test public void decreaseMGP() { MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator(); Coin prev = Coin.valueOf(1000L); Coin target = Coin.valueOf(900L); Coin mgp = mgpCalculator.calculate(prev, target); Assert.assertEquals(Coin.valueOf(990), mgp); }
@Test public void mgpOnRage() { MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator(); Coin prev = Coin.valueOf(1000L); Coin target = Coin.valueOf(995L); Coin mgp = mgpCalculator.calculate(prev, target); Assert.assertEquals(target, mgp); }
@Test public void previousMgpEqualsTarget() { MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator(); Coin prev = Coin.valueOf(1000L); Coin target = Coin.valueOf(1000L); Coin mgp = mgpCalculator.calculate(prev, target); Assert.assertEquals(target, mgp); }
@Test public void previousValueIsZero() { MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator(); Coin target = Coin.valueOf(1000L); Coin mgp = mgpCalculator.calculate(Coin.ZERO, target); Assert.assertEquals(Coin.valueOf(1L), mgp); }
@Test public void previousValueIsSmallTargetIsZero() { MinimumGasPriceCalculator mgpCalculator = new MinimumGasPriceCalculator(); Coin target = Coin.ZERO; Coin mgp = mgpCalculator.calculate(Coin.valueOf(1L), target); Assert.assertEquals(Coin.ZERO, mgp); }