### Question:
ExtractorMajorPartQuery implements MonetaryQuery<Long> { @Override public Long queryFrom(MonetaryAmount amount) { Objects.requireNonNull(amount, "Amount required."); return amount.with(downRounding).getNumber().longValueExact(); } ExtractorMajorPartQuery(); @Override Long queryFrom(MonetaryAmount amount);  }### Answer:
@Test(expectedExceptions = NullPointerException.class) public void shouldReturnNPEWhenTheMonetaryAmountIsNull() { query.queryFrom(null); fail(); }
@Test(expectedExceptions = ArithmeticException.class) public void shouldReturnWhenTheValueIsBiggerThanLong() { CurrencyUnit real = Monetary.getCurrency("BRL"); MonetaryAmount monetaryAmount = Money.of(Long.MAX_VALUE, real); query.queryFrom(monetaryAmount.add(Money.of(10, real))); fail(); }
@Test public void shouldReturnMajorPartPositive() { MonetaryAmount monetaryAmount = Money.parse("EUR 2.35"); Long result = query.queryFrom(monetaryAmount); Long expected = 2L; assertEquals(result, expected ); }
@Test public void shouldReturnMajorPartNegative() { MonetaryAmount monetaryAmount = Money.parse("BHD -1.345"); Long result = query.queryFrom(monetaryAmount); Long expected = -1L; assertEquals(result, expected ); }