@@ -0,0 +1,2398 @@
+/*%0A */%0Apackage org.datadryad.journalstatistics.extractor;%0A%0Aimport java.sql.SQLException;%0Aimport java.text.DateFormat;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Calendar;%0Aimport java.util.Date;%0Aimport java.util.GregorianCalendar;%0Aimport org.datadryad.api.DryadDataFile;%0Aimport org.dspace.core.Context;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0A%0A/**%0A *%0A * @author Dan Leehr %3Cdan.leehr@nescent.org%3E%0A */%0Apublic class EmbargoedDataFileCountTest %7B%0A%0A    private Context context;%0A    private Date futureDate;%0A%0A    @Before%0A    public void setUp() %7B%0A        try %7B%0A            this.context = new Context();%0A            context.turnOffAuthorisationSystem();%0A            Calendar calendar = new GregorianCalendar();%0A            calendar.set(Calendar.YEAR, 9999);%0A            calendar.set(Calendar.MONTH, 1);%0A            calendar.set(Calendar.DAY_OF_MONTH, 1);%0A            futureDate = calendar.getTime();%0A        %7D catch (SQLException ex) %7B%0A            fail(%22Unable to instantiate Context %22 + ex);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Test of extract method, of class DataPackageCount.%0A     * Data packages are items in collection identified by 'stats.datapkgs.coll'%0A     * having prism.publicationName as provided%0A     */%0A    @Test%0A    public void testCountEmbargoedDataFiles() throws SQLException %7B%0A        // Count the initial number of embargoed data files%0A        String journalName = %22Test Journal%22;%0A        EmbargoedDataFileCount instance = new EmbargoedDataFileCount(this.context);%0A        Integer initialCount = instance.extract(journalName);%0A        // Create a new data package, do not set an embargo, assert the count does not change%0A        DryadDataFile dataFile = DryadDataFile.create(context);%0A        dataFile.setPublicationName(journalName);%0A        Integer expResult = initialCount;%0A        Integer result = instance.extract(journalName);%0A        assertEquals(expResult, result);%0A%0A        // embargo the file and assert the count changes%0A        dataFile.setEmbargo(%22custom%22, futureDate );%0A        result = instance.extract(journalName);%0A        expResult = initialCount + 1;%0A        assertEquals(expResult, result);%0A%0A        // Clear the embargo and assert the count goes back down%0A        dataFile.clearEmbargo();%0A        result = instance.extract(journalName);%0A        expResult = initialCount;%0A        assertEquals(expResult, result);%0A    %7D%0A%7D%0A

Test for EmbargoedDataFileCount