User implements Serializable { public Set<String> getOpAuths() { return Collections.unmodifiableSet(opAuths); } User();  User(final String userId);  User(final String userId, final Set<String> dataAuths);  User(final String userId, final Set<String> dataAuths, final Set<String> opAuths); String getUserId(); Set<String> getDataAuths(); Set<String> getOpAuths(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); static final String UNKNOWN_USER_ID; }
@Test public void shouldNotAllowChangingOpAuths() { final String userId = "user 01"; final String opAuth1 = "opAuth 1"; final String opAuth2 = "opAuth 2"; final String newOpAuth = "new opAuth"; final User user = new User.Builder() .userId(userId) .opAuth(opAuth1) .opAuth(opAuth2) .build(); try { user.getOpAuths().add(newOpAuth); fail("Exception expected"); } catch (final UnsupportedOperationException e) { assertNotNull(e); } assertFalse(user.getOpAuths().contains(newOpAuth)); }