AddInverse implements Scalar<T> { @Override public T value(final Field<T> field) { return field.addition().inverse(field.actual(this.inverse)); } AddInverse(final Scalar<T> inv); @Override T value(final Field<T> field);  }
@Test public void addInverseDelegatesToFieldAddition() { final MkAddition<Object> add = new MkAddition<>(new String()); final SpyField<Object> field = new SpyField<>( new MkField<Object>(new Object(), add) ); final Scalar<Object> scalar = new Scalar.Default<>(new Object()); new AddInverse<>(scalar).value(field); MatcherAssert.assertThat( add.inverted(), Matchers.is(true) ); MatcherAssert.assertThat( field.calls().additioned(), Matchers.is(true) ); }