PermissionsManager { public AbstractPermissionsDomain<? extends AbstractPermissions> getDomain(String domain) throws NotFoundException { return getPermissionsDao(domain).getDomain(); } @Inject  PermissionsManager(
      EventService eventService, Set<PermissionsDao<? extends AbstractPermissions>> daos); void storePermission(Permissions permissions); AbstractPermissions get(String userId, String domainId, String instanceId); @SuppressWarnings("unchecked") Page<AbstractPermissions> getByInstance(
      String domainId, String instanceId, int maxItems, long skipCount); void remove(String userId, String domainId, String instanceId); boolean exists(String userId, String domainId, String instanceId, String action); void checkActionsSupporting(String domainId, List<String> actions); List<AbstractPermissionsDomain> getDomains(); AbstractPermissionsDomain<? extends AbstractPermissions> getDomain(String domain);  }
@Test( expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Permissions Domain 'test' should be stored in only one storage. " + "Duplicated in class org.eclipse.che.multiuser.api.permission.server.spi.PermissionsDao.* and class org.eclipse.che.multiuser.api.permission.server.spi.PermissionsDao.*") public void shouldThrowExceptionIfThereAreTwoStoragesWhichServeOneDomain() throws Exception { @SuppressWarnings("unchecked") final PermissionsDao anotherStorage = mock(PermissionsDao.class); when(anotherStorage.getDomain()).thenReturn(new TestDomain()); permissionsManager = new PermissionsManager(eventService, ImmutableSet.of(permissionsDao, anotherStorage)); }
@Test public void shouldBeAbleToDomainActions() throws Exception { final PermissionsDomain testDomain = permissionsManager.getDomain("test"); final List<String> allowedActions = testDomain.getAllowedActions(); assertEquals(allowedActions.size(), 5); assertTrue( allowedActions.containsAll( ImmutableSet.of(SET_PERMISSIONS, "read", "write", "use", "delete"))); }
@Test( expectedExceptions = NotFoundException.class, expectedExceptionsMessageRegExp = "Requested unsupported domain 'unsupported'") public void shouldThrowExceptionWhenRequestedUnsupportedDomain() throws Exception { permissionsManager.getDomain("unsupported"); }