@Test
public void testScheduleNewEventPermissions() throws Exception
{

    // Create Channels as Admin
    testHelper.mockChannelType(channelTypeId);
    Channel publishChannel = testHelper.createChannel(channelTypeId);
    Channel statusChannel = testHelper.createChannel(channelTypeId);
    
    NodeRef firstNode = createContent("First");
    NodeRef secondNode = createContent("Second");
    
    // Create User1, add read permissions and set as current user.
    String user1 = GUID.generate();
    personManager.createPerson(user1);
    testHelper.setChannelPermission(user1, publishChannel.getId(), PermissionService.READ);
    testHelper.setChannelPermission(user1, statusChannel.getId(), PermissionService.READ);
    personManager.setUser(user1);
    // Publish an event
    PublishingDetails details = publishingService.createPublishingDetails();
    details.addNodesToPublish(firstNode, secondNode);
    details.setPublishChannelId(publishChannel.getId());
    try
    {
        testHelper.scheduleEvent1Year(details);
        fail("shceduleNewEvent should have thrown an AccessDeniedException!");
    }
    catch(AlfrescoRuntimeException e)
    {
        //NOOP
    }
    
    // Set Add Child permission on publish channel.
    testHelper.allowChannelAccess(user1, publishChannel.getId());
    
    // Check publish works now.
    String eventId = testHelper.scheduleEvent1Year(details);
    assertNotNull(eventId);
    
    String message = "The message";
    details.setStatusMessage(message)
        .setStatusNodeToLinkTo(secondNode)
        .addStatusUpdateChannels(statusChannel.getId());
    try
    {
        eventId = testHelper.scheduleEvent1Year(details);
        fail("shceduleNewEvent with status update should have thrown an AccessDeniedException!");
    }
    catch(AlfrescoRuntimeException e)
    {
        //NOOP
    }
    
    // Set Add Child permission on status channel.
    testHelper.allowChannelAccess(user1, statusChannel.getId());
    // Check publish works now.
    eventId = testHelper.scheduleEvent1Year(details);
    assertNotNull(eventId);
}