Aer implements Comparable<Aer> { public Aer add(final Aer other) { assertNotNull(other, "Other is null"); assertNotEquals(Aer.EMPTY, this, "Cannot add to Aer.EMPTY"); assertNotEquals(Aer.EMPTY, other, "Cannot add with Aer.EMPTY"); if (null == this.value) { return other; } if (null == other.value) { return this; } return new Aer(this.value.add(other.value)); } Aer(final String amount);  Aer(final String amount, final Unit unit);  Aer(final BigInteger amount); protected  Aer(); static Aer of(final String amount); static Aer of(final String amount, final Unit unit); static Aer of(final BigInteger amount); Aer add(final Aer other); Aer subtract(final Aer other); @Override int compareTo(final Aer other); @Override String toString(); String toString(final Unit unit); static final String EMPTY_STRING; static final Aer EMPTY; static final Aer ZERO; static final Aer ONE; static final Aer GIGA_ONE; static final Aer AERGO_ONE; }
@Test public void testAdd() { final Aer left = Aer.of("1", Unit.AER); final Aer right = Aer.of("2", Unit.AER); assertEquals(Aer.of("3", Unit.AER), left.add(right)); }
@Test public void shouldAddFailOnEmptyOperand() { final Object[][] parameters = new Object[][] { {Aer.EMPTY, Aer.ONE}, {Aer.ONE, Aer.EMPTY} }; for (final Object[] parameter : parameters) { final Aer left = (Aer) parameter[0]; final Aer right = (Aer) parameter[1]; try { left.add(right); fail(); } catch (AssertionError e) { } } }