/*
 */
package org.datadryad.journalstatistics.extractor;

import java.sql.SQLException;
import org.dspace.core.Context;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Dan Leehr <dan.leehr@nescent.org>
 */
public class DataPackageCountTest {

    private Context context;
    public DataPackageCountTest() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
        try {
            this.context = new Context();
        } catch (SQLException ex) {
            fail("Unable to instantiate Context " + ex);
        }
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of extract method, of class DataPackageCount.
     * Data packages are items in collection identified by 'stats.datapkgs.coll'
     * having prism.publicationName as provided
     */
    @Test
    public void testExtract() {
        // There should be one package in the database with journal name "Test Journal"
        System.out.println("extract");
        String journalName = "Test Journal";
        DataPackageCount instance = new DataPackageCount(this.context);
        Integer expResult = 1;
        Integer result = instance.extract(journalName);
        assertEquals(expResult, result);
    }
}

@@ -82,16 +82,148 @@
 eption;%0A
+import org.datadryad.api.DryadDataPackage;%0Aimport org.dspace.authorize.AuthorizeException;%0Aimport org.dspace.content.WorkspaceItem;%0A
 import o
@@ -1196,19 +1196,39 @@
 xtract()
+ throws SQLException
  %7B%0A
-
         
@@ -1319,83 +1319,231 @@
     
-System.out.println(%22extract%22);%0A        String journalName = %22Test Journal%22;
+// Create a data package%0A        DryadDataPackage dataPackage = DryadDataPackage.create(context);%0A        // set its journal%0A        String journalName = %22Test Journal%22;%0A        dataPackage.setPublicationName(journalName);%0A
 %0A   

Update test to create a data package before count