/*
 */
package org.dspace.workflow;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import org.apache.log4j.Logger;
import org.datadryad.api.DryadDataPackage;
import org.datadryad.test.ContextUnitTest;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Dan Leehr <dan.leehr@nescent.org>
 */
public class AutoApproveBlackoutProcessorTest extends ContextUnitTest {
    private static Logger log = Logger.getLogger(AutoApproveBlackoutProcessorTest.class);
    private Calendar calendar;
    private Date pastDate;
    private Date nowDate;
    private Date futureDate;

    @Before
    public void setUp() {
        super.setUp();
        calendar = new GregorianCalendar();
        nowDate = calendar.getTime();
        int currentYear = calendar.get(Calendar.YEAR);
        calendar.set(Calendar.YEAR, currentYear - 1);
        pastDate = calendar.getTime();
        calendar.set(Calendar.YEAR, currentYear + 1);
        futureDate = calendar.getTime();
    }

    @Test
    public void testApproveFromBlackoutWithPastDate() throws Exception {
        // test that an item in blackout can be approved
        DryadDataPackage dataPackage = DryadDataPackage.createInWorkflow(context);
        AutoCurateToBlackoutProcessor curateToBlackoutProcessor = new AutoCurateToBlackoutProcessor(context);
        Boolean curatedToBlackout = curateToBlackoutProcessor.processWorkflowItem(dataPackage.getWorkflowItem(context));
        assertTrue("Could not curate new item to blackout", curatedToBlackout);

        // Now, item is in blackout, test that it can be approved
        dataPackage.setBlackoutUntilDate(pastDate); // Set the blackoutUntil date to be the past
        AutoApproveBlackoutProcessor approveBlackoutProcessor = new AutoApproveBlackoutProcessor(context);
        Boolean approvedFromBlackout = approveBlackoutProcessor.processWorkflowItem(dataPackage.getWorkflowItem(context));
        assertTrue("Could not approve item from blackout to archive", approvedFromBlackout);

        Boolean archived = dataPackage.getItem().isArchived();
        assertTrue("Item should be archived", archived);
    }

    /**
     * Test of getActionID method, of class AutoApproveBlackoutProcessor.
     */
    @Test
    public void testGetActionID() {
        log.info("getActionID");
        AutoApproveBlackoutProcessor instance = new AutoApproveBlackoutProcessor(context);
        String expResult = "afterPublicationAction";
        String result = instance.getActionID();
        assertEquals("Blackout processor's action mismatch", expResult, result);
    }

}

@@ -230,24 +230,65 @@
 xtUnitTest;%0A
+import org.dspace.content.WorkspaceItem;%0A
 import org.j
@@ -505,16 +505,22 @@
  static 
+final 
 Logger l
@@ -1097,182 +1097,560 @@
     
-@Test%0A    public void testApproveFromBlackoutWithPastDate() throws Exception %7B%0A        // test that an item in blackout can be approved%0A        DryadDataPackage dataPackage =
+/**%0A     * Tests that an item in blackout can be approved.%0A     * Creates a bare item in the workspace and invokes two processors to%0A     * send it to blackout then archive%0A     * @throws Exception%0A     */%0A    @Test%0A    public void testApproveFromBlackoutWithPastDate() throws Exception %7B%0A        DryadDataPackage dataPackage = DryadDataPackage.createInWorkspace(context);%0A        WorkspaceItem wsi = dataPackage.getWorkspaceItem(context);%0A%0A        // Uses WorkflowManager.start(), which invokes the entire workflow process%0A        // Other tests using
  Dry
@@ -1654,33 +1654,40 @@
 DryadDataPackage
-.
+ simply 
 createInWorkflow
@@ -1686,24 +1686,117 @@
 Workflow
+, as they do not%0A        // need the entire set of tasks/steps.%0A        WorkflowManager.start
 (context
 );%0A     
@@ -1779,35 +1779,41 @@
 er.start(context
+, wsi
 );%0A
+%0A
         AutoCura

Update Test to use WorkflowManager.start()