UpdateViewHook implements GraphHook { protected final boolean validateAuths(final Set<String> userAuths, final Set<String> validAuth, final boolean ifValidAuthIsNull) { boolean rtn = ifValidAuthIsNull; if (null != validAuth) { if (null == userAuths) { rtn = validAuth.isEmpty(); } else { rtn = CollectionUtils.containsAny(userAuths, validAuth); } } return rtn; }  @Override void preExecute(final OperationChain<?> opChain, final Context context); @Override T postExecute(final T result, final OperationChain<?> opChain, final Context context); @Override T onFailure(final T result, final OperationChain<?> opChain, final Context context, final Exception e); Set<String> getWithOpAuth(); UpdateViewHook setWithOpAuth(final Set<String> withOpAuth); Set<String> getWithoutOpAuth(); UpdateViewHook setWithoutOpAuth(final Set<String> withoutOpAuth); Set<String> getWithDataAuth(); UpdateViewHook setWithDataAuth(final Set<String> withDataAuth); Set<String> getWithoutDataAuth(); UpdateViewHook setWithoutDataAuth(final Set<String> withoutDataAuth); Set<String> getWhiteListElementGroups(); UpdateViewHook setWhiteListElementGroups(final Set<String> whiteListElementGroups); Set<String> getBlackListElementGroups(); UpdateViewHook setBlackListElementGroups(final Set<String> blackListElementGroups); UpdateViewHook setViewToMerge(final View viewToMerge); View getViewToMerge(); boolean isAddExtraGroups(); UpdateViewHook setAddExtraGroups(final boolean addExtraGroups); static final boolean ADD_EXTRA_GROUPS_DEFAULT; }
@Test public void shouldPassExcessAuth() throws Exception { userAuths.add(A); userAuths.add(B); validAuths.add(A); assertTrue(updateViewHook.validateAuths(userAuths, validAuths, true)); }
@Test public void shouldPassSubsetAuth() throws Exception { userAuths.add(A); validAuths.add(A); validAuths.add(B); assertTrue(updateViewHook.validateAuths(userAuths, validAuths, true)); }
@Test public void shouldFailMissingAuth() throws Exception { userAuths.add(B); validAuths.add(A); assertFalse(updateViewHook.validateAuths(userAuths, validAuths, true)); }
@Test public void shouldFailEmptyUserAuths() throws Exception { validAuths.add(A); assertFalse(updateViewHook.validateAuths(userAuths, validAuths, true)); }
@Test public void shouldFailNullUserAuths() throws Exception { validAuths.add(A); assertFalse(updateViewHook.validateAuths(null, validAuths, true)); }
@Test public void shouldPassNullValid() throws Exception { assertTrue(updateViewHook.validateAuths(userAuths, null, true)); }