Package com.adito.policyframework

Examples of com.adito.policyframework.Resource


    /**
     */
    @Test
    public void isResourceNameInUse() {
        Resource resource = getDefaultResource();
        String resourceName = resource.getResourceName();

        expect(resourceDatabase.isResourceNameInUse(resourceName, 1)).andReturn(false);
        mocksControl.replay();

        resourceService.isResourceNameInUse(resourceName, null);
View Full Code Here


    /**
     */
    @Test
    public void getResourceById() {
        Resource resource = getDefaultResource();
        int resourceId = resource.getResourceId();

        expect(resourceDatabase.getResourceById(resourceId)).andReturn(resource);
        mocksControl.replay();

        resourceService.getResourceById(resourceId);
View Full Code Here

    /**
     */
    @Test
    public void getResourceByName() {
        Resource resource = getDefaultResource();
        String resourceName = resource.getResourceName();

        expect(resourceDatabase.getResourceByName(resourceName, 1)).andReturn(resource);
        mocksControl.replay();

        resourceService.getResourceByName(resourceName, null);
View Full Code Here

    /**
     * @throws DuplicateResourceNameException
     */
    @Test
    public void createResource() throws DuplicateResourceNameException {
        Resource resource = getDefaultResource();

        expect(resourceDatabase.isResourceNameInUse(resource.getResourceName(), 1)).andReturn(false);
        expect(resourceDatabase.insertResource(resource)).andReturn(1);
        CoreEvent changeEvent = getChangeEvent(resourceService.getCreateEventId(), CoreEvent.STATE_SUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
        expect(resourceDatabase.getResourceById(1)).andReturn(resource);
        mocksControl.replay();
View Full Code Here

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

        expect(resourceDatabase.isResourceNameInUse(resource.getResourceName(), 1)).andReturn(true);
        CoreEvent changeEvent = getChangeEvent(resourceService.getCreateEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
        mocksControl.replay();

        try {
View Full Code Here

    /**
     * @throws DuplicateResourceNameException
     */
    @Test
    public void createResourceWithDataAccessException() throws DuplicateResourceNameException {
        Resource resource = getDefaultResource();

        expect(resourceDatabase.isResourceNameInUse(resource.getResourceName(), 1)).andReturn(false);
        expect(resourceDatabase.insertResource(resource)).andThrow(
            new DataAccessException("Failed to insert resource."));
        CoreEvent changeEvent = getChangeEvent(resourceService.getCreateEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
        mocksControl.replay();
View Full Code Here

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

        expect(resourceDatabase.getResourceById(resource.getResourceId())).andReturn(resource);
        policyService.checkPermission(resourceType, PolicyConstants.PERM_EDIT_AND_ASSIGN, (SessionInfo) null);
        resourceDatabase.updateResource(resource);
        CoreEvent changeEvent = getChangeEvent(resourceService.getEditEventId(), CoreEvent.STATE_SUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
        mocksControl.replay();
View Full Code Here

    /**
     * @throws NoPermissionException
     */
    @Test
    public void updateDuplicateResource() throws NoPermissionException {
        Resource resource = getDefaultResource();
        Resource updatedResource = getDefaultResource();
        updatedResource.setResourceName("updatedResourceName");
       
        expect(resourceDatabase.getResourceById(resource.getResourceId())).andReturn(updatedResource);
        expect(resourceDatabase.isResourceNameInUse(resource.getResourceName(), 1)).andReturn(true);
        CoreEvent changeEvent = getChangeEvent(resourceService.getEditEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
View Full Code Here

     * @throws DuplicateResourceNameException
     * @throws NoPermissionException
     */
    @Test
    public void updateResourceWithNoPermissionException() throws DuplicateResourceNameException, NoPermissionException {
        Resource resource = getDefaultResource();
       
        expect(resourceDatabase.getResourceById(resource.getResourceId())).andReturn(resource);
        policyService.checkPermission(resourceType, PolicyConstants.PERM_EDIT_AND_ASSIGN, (SessionInfo) null);
        expectLastCall().andThrow(new NoPermissionException("Failed to update resource."));
        CoreEvent changeEvent = getChangeEvent(resourceService.getEditEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
        mocksControl.replay();
View Full Code Here

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

        expect(resourceDatabase.getResourceById(resource.getResourceId())).andReturn(resource);
        policyService.checkPermission(resourceType, PolicyConstants.PERM_EDIT_AND_ASSIGN, (SessionInfo) null);
        resourceDatabase.updateResource(resource);
        expectLastCall().andThrow(new DataAccessException("Failed to update resource."));
        CoreEvent changeEvent = getChangeEvent(resourceService.getEditEventId(), CoreEvent.STATE_UNSUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
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.