### Question:
ReciprocalOperator implements MonetaryOperator { @Override public MonetaryAmount apply(MonetaryAmount amount) { requireNonNull(amount, "Amount required."); NumberValue num = amount.getNumber(); BigDecimal one = ONE.setScale(num.getScale() < 5 ? 5 : num.getScale(), HALF_EVEN); BigDecimal reciprocal = one.divide(num.numberValue(BigDecimal.class), HALF_EVEN); return amount.getFactory().setNumber(reciprocal).create(); } ReciprocalOperator(); @Override MonetaryAmount apply(MonetaryAmount amount);  }### Answer:
@Test public void shouldReturnPositiveValue() { CurrencyUnit currency = Monetary.getCurrency("EUR"); MonetaryAmount money = Money.parse("EUR 2.0"); MonetaryAmount result = operator.apply(money); assertEquals(result.getCurrency(), currency); assertEquals(result.getNumber().doubleValue(), 0.5); }
@Test public void shouldReturnNegativeValue() { CurrencyUnit currency = Monetary.getCurrency("EUR"); MonetaryAmount money = Money.parse("EUR -2.0"); MonetaryAmount result = operator.apply(money); assertEquals(result.getCurrency(), currency); assertEquals(result.getNumber().doubleValue(), -0.5); }
@Test(expectedExceptions = NullPointerException.class) public void shouldReturnErrorWhenIsNull() { operator.apply(null); }