UserNamespaceAuthorizationHelper { public Set<NamespaceAuthorization> getAllNamespaceAuthorizations() { Set<NamespaceAuthorization> namespaceAuthorizations = new LinkedHashSet<>(); List<NamespaceKey> namespaceKeys = namespaceDao.getNamespaces(); for (NamespaceKey namespaceKey : namespaceKeys) { NamespaceAuthorization namespaceAuthorization = new NamespaceAuthorization(); namespaceAuthorizations.add(namespaceAuthorization); namespaceAuthorization.setNamespace(namespaceKey.getNamespaceCode()); namespaceAuthorization.setNamespacePermissions(getAllNamespacePermissions()); } return namespaceAuthorizations; }  void buildNamespaceAuthorizations(ApplicationUser applicationUser); Set<NamespaceAuthorization> getAllNamespaceAuthorizations(); List<NamespacePermissionEnum> getNamespacePermissions(UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity);  }
@Test public void testGetAllNamespaceAuthorizations() { List<NamespaceKey> namespaceKeys = new ArrayList<>(); namespaceKeys.add(new NamespaceKey(NAMESPACE_CODE)); when(namespaceDao.getNamespaces()).thenReturn(namespaceKeys); List<NamespaceAuthorization> namespaceAuthorizations = new ArrayList<>(userNamespaceAuthorizationHelper.getAllNamespaceAuthorizations()); assertThat(namespaceAuthorizations.get(0).getNamespace(), is(NAMESPACE_CODE)); assertThat(namespaceAuthorizations.get(0).getNamespacePermissions().contains(NamespacePermissionEnum.EXECUTE), is(true)); assertThat(namespaceAuthorizations.get(0).getNamespacePermissions().contains(NamespacePermissionEnum.GRANT), is(true)); assertThat(namespaceAuthorizations.get(0).getNamespacePermissions().contains(NamespacePermissionEnum.READ), is(true)); assertThat(namespaceAuthorizations.get(0).getNamespacePermissions().contains(NamespacePermissionEnum.WRITE), is(true)); assertThat(namespaceAuthorizations.get(0).getNamespacePermissions().contains(NamespacePermissionEnum.WRITE_ATTRIBUTE), is(true)); assertThat(namespaceAuthorizations.get(0).getNamespacePermissions().contains(NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT), is(true)); verify(namespaceDao).getNamespaces(); verifyNoMoreInteractions(namespaceDao, userNamespaceAuthorizationDao, wildcardHelper); }