MutableStatusDetailIndicator implements StatusDetailIndicator { public void update(final StatusDetail statusDetail) { if (!this.statusDetail.getName().equals(statusDetail.getName())) { throw new IllegalArgumentException("Must not update StatusDetail with different names. That would be confusing."); } this.statusDetail = requireNonNull(statusDetail, "Parameter StatusDetail must not be null"); } MutableStatusDetailIndicator(final StatusDetail initialStatusDetail); @Override List<StatusDetail> statusDetails(); void update(final StatusDetail statusDetail); void toOk(String message); void toWarning(String message); void toError(String message); void withDetail(String key, String value); void withoutDetail(String key);  }
@Test public void shouldFailToUpdateStatusWithDifferentName() { final MutableStatusDetailIndicator indicator = new MutableStatusDetailIndicator(statusDetail("foo", OK, "message")); assertThrows(IllegalArgumentException.class, () -> { indicator.update(statusDetail("bar", OK, "message")); }); }