HttpPermissionCheckerImpl implements PermissionChecker { @Override public boolean hasPermission(String user, String domain, String instance, String action) throws ServerException { try { return permissionsCache.get(new Key(user, domain, instance)).contains(action); } catch (Exception e) { throw new ServerException(e.getMessage(), e); } } @Inject  HttpPermissionCheckerImpl(
      @Named("che.api") String apiEndpoint, HttpJsonRequestFactory requestFactory); @Override boolean hasPermission(String user, String domain, String instance, String action);  }
@Test public void shouldCheckPermissionsByHttpRequestToPermissionsService() throws Exception { when(response.asDto(anyObject())) .thenReturn( DtoFactory.newDto(PermissionsDto.class) .withUserId("user123") .withDomainId("domain123") .withInstanceId("instance123") .withActions(asList("read", "test"))); final boolean hasPermission = httpPermissionChecker.hasPermission("user123", "domain123", "instance123", "test"); assertEquals(hasPermission, true); verify(requestFactory) .fromUrl( eq( UriBuilder.fromUri(API_ENDPOINT) .path(PermissionsService.class) .path(PermissionsService.class, "getCurrentUsersPermissions") .queryParam("instance", "instance123") .build("domain123") .toString())); verify(request).useGetMethod(); verify(request).request(); verifyNoMoreInteractions(request); }