User implements Serializable { public Set<String> getDataAuths() { return Collections.unmodifiableSet(dataAuths); } 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 shouldNotAllowChangingDataAuths() { final String userId = "user 01"; final String dataAuth1 = "dataAuth 1"; final String dataAuth2 = "dataAuth 2"; final String newDataAuth = "new dataAuth"; final User user = new User.Builder() .userId(userId) .dataAuth(dataAuth1) .dataAuth(dataAuth2) .build(); try { user.getDataAuths().add(newDataAuth); fail("Exception expected"); } catch (final UnsupportedOperationException e) { assertNotNull(e); } assertFalse(user.getDataAuths().contains(newDataAuth)); }