Package com.adito.policyframework

Examples of com.adito.policyframework.Resource


    /**
     * @throws NoPermissionException
     */
    @Test
    public void removeResource() throws NoPermissionException {
        Resource resource = getDefaultResource();

        policyService.checkPermission(resourceType, PolicyConstants.PERM_DELETE, (SessionInfo) null);
        expect(resourceDatabase.removeResource(resource.getResourceId())).andReturn(resource);
        CoreEvent deleteEvent = getDeleteEvent(resourceService.getRemoveEventId(), CoreEvent.STATE_SUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(deleteEvent));
        mocksControl.replay();

        resourceService.removeResource(resource.getResourceId(), null);
        mocksControl.verify();
    }
View Full Code Here


    /**
     * @throws NoPermissionException
     */
    @Test
    public void removeResourceWithNoPermissionException() throws NoPermissionException {
        Resource resource = getDefaultResource();

        policyService.checkPermission(resourceType, PolicyConstants.PERM_DELETE, (SessionInfo) null);
        expectLastCall().andThrow(new NoPermissionException("Failed to remove resource."));
        CoreEvent deleteEvent = getDeleteEvent(resourceService.getRemoveEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(deleteEvent));
        mocksControl.replay();

        try {
            resourceService.removeResource(resource.getResourceId(), null);
            fail("Should have thrown an exception");
        } catch (NoPermissionException e) {
            // nothing to do
        }

View Full Code Here

    /**
     * @throws NoPermissionException
     */
    @Test
    public void removeResourceWithDataAccessException() throws NoPermissionException {
        Resource resource = getDefaultResource();

        policyService.checkPermission(resourceType, PolicyConstants.PERM_DELETE, (SessionInfo) null);
        resourceDatabase.removeResource(resource.getResourceId());
        expectLastCall().andThrow(new DataAccessException("Failed to remove resource."));
        CoreEvent deleteEvent = getDeleteEvent(resourceService.getRemoveEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(deleteEvent));
        mocksControl.replay();

        try {
            resourceService.removeResource(resource.getResourceId(), null);
            fail("Should have thrown an exception");
        } catch (DataAccessException e) {
            // nothing to do
        }

View Full Code Here

   
    /**
     */
    @Test
    public void getResourceById() {
        Resource resource = getDefaultResource();
        expect(resourceService.getResourceById(123)).andReturn(resource);
        replay(resourceService);
        Resource foundResource = resourceType.getResourceById(123);
        verify(resourceService);
        assertEquals("Resource matches", resource, foundResource);
    }
View Full Code Here

   
    /**
     */
    @Test
    public void getResourceByName() {
        Resource resource = getDefaultResource();
        expect(resourceService.getResourceByName("resourceName", null)).andReturn(resource);
        replay(resourceService);
        Resource foundResource = resourceType.getResourceByName("resourceName", null);
        verify(resourceService);
        assertEquals("Resource matches", resource, foundResource);
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void createResource() throws Exception {
        Resource resource = getDefaultResource();
        expect(resourceService.createResource(resource, null)).andReturn(resource);
        replay(resourceService);
        resourceType.createResource(resource, null);
        verify(resourceService);
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void updateResource() throws Exception {
        Resource resource = getDefaultResource();
        resourceService.updateResource(resource, null);
        replay(resourceService);
        resourceType.updateResource(resource, null);
        verify(resourceService);
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void removeResource() throws Exception {
        Resource resource = getDefaultResource();
        expect(resourceService.removeResource(123, null)).andReturn(resource);
        replay(resourceService);
        Resource foundResource = resourceType.removeResource(123, null);
        verify(resourceService);
        assertEquals("Resource matches", resource, foundResource);
    }  
View Full Code Here

      return information(mapping, form, request, response);
    }

    public ActionForward information(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        Resource r = (Resource)request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE);
        Collection<Policy> policies = null;
        if(r.getResourceType().isPolicyRequired()) {
            policies = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(r, getSessionInfo(request).getRealm());
        }
      ((ResourceInformationForm)form).initialise(r, policies);
        return mapping.findForward("display");
    }
View Full Code Here

            super(SAMPLE_RESOURCE_TYPE_ID, "sample", PolicyConstants.DELEGATION_CLASS);
        }

        public WrappedFavoriteItem createWrappedFavoriteItem(int resourceId, HttpServletRequest request, String type)
                        throws Exception {
            Resource r = getResourceById(resourceId);
            if (r == null) {
                return null;
            }
            return new WrappedFavoriteItem(new SampleItem((Sample) r, CoreServlet.getServlet().getPolicyDatabase()
                .getPoliciesAttachedToResource(r)), type);
View Full Code Here

TOP

Related Classes of com.adito.policyframework.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.