EventCount { public static EventCount of(long success, long failure) { if (success == 0 && failure == 0) { return ZERO; } return new EventCount(success, failure); } private  EventCount(long success, long failure); static EventCount of(long success, long failure); long success(); long failure(); long total(); double successRate(); double failureRate(); @Override int hashCode(); @Override boolean equals(@Nullable Object o); @Override String toString(); static final EventCount ZERO; }
@Test void testInvalidArguments() { assertThatThrownBy(() -> EventCount.of(-1, 0)).isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> EventCount.of(0, -1)).isInstanceOf(IllegalArgumentException.class); }