/*
 */
package org.datadryad.api;

import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import org.datadryad.test.ContextUnitTest;
import org.dspace.content.Collection;
import org.dspace.content.DCValue;
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 DryadDataFileTest extends ContextUnitTest {

    private Calendar calendar;
    private Date pastDate;
    private Date nowDate;
    private Date futureDate;
    public DryadDataFileTest() {
    }

    @BeforeClass
    public static void setUpClass() {
    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void 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();
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of getCollection method, of class DryadDataFile.
     */
    @Test
    public void testGetCollection() throws Exception {
        Context context = this.context;
        Collection result = DryadDataFile.getCollection(context);
        assertEquals(result.getName(), "Dryad Data Files");
    }

    /**
     * Test of create method, of class DryadDataFile.
     */
    @Test
    public void testCreate() throws Exception {
        DryadDataFile result = DryadDataFile.create(context);
        assertNotNull(result);
    }

    /**
     * Test of getDataPackage method, of class DryadDataFile.
     */
    @Test
    public void testGetDataPackage() {
        fail("The test case is a prototype.");
    }

    /**
     * Test of parseDate method, of class DryadDataFile.
     */
    @Test
    public void testParseDate() throws Exception {
        String dateString = "2014-06-12";
        Date expResult = null;
        Date result = DryadDataFile.parseDate(dateString);
        calendar.setTime(result);
        assertEquals(calendar.get(Calendar.YEAR), 2014);
        assertEquals(calendar.get(Calendar.MONTH), Calendar.JUNE);
        assertEquals(calendar.get(Calendar.DAY_OF_MONTH), 12);
    }

    /**
     * Test of formatDate method, of class DryadDataFile.
     */
    @Test
    public void testFormatDate() {
        calendar.set(Calendar.YEAR, 2015);
        calendar.set(Calendar.MONTH, Calendar.JULY);
        calendar.set(Calendar.DAY_OF_MONTH, 25);
        String expResult = "2015-07-25";
        String result = DryadDataFile.formatDate(calendar.getTime());
        assertEquals(expResult, result);
    }


    /**
     * Test of getEarliestDate method, of class DryadDataFile.
     */
    @Test
    public void testGetEarliestDate_DateArr() {
        System.out.println("getEarliestDate");
        Date[] dates = {
            futureDate,
            pastDate,
            nowDate
        };
        Date expResult = pastDate;
        Date result = DryadDataFile.getEarliestDate(dates);
        assertEquals(expResult, result);
    }

    /**
     * Test of isEmbargoed method, of class DryadDataFile.
     */
    @Test
    public void testIsEmbargoed() throws SQLException {
        System.out.println("isEmbargoed");
        DryadDataFile instance = DryadDataFile.create(context);
        // not initially embargoed, so set one in the past
        instance.setEmbargo("oneyear", futureDate);
        assertTrue(instance.isEmbargoed());
        instance.setEmbargo("oneyear", pastDate);
        assertFalse(instance.isEmbargoed());
    }

    /**
     * Test of clearEmbargo method, of class DryadDataFile.
     */
    @Test
    public void testClearEmbargo() throws Exception {
        System.out.println("clearEmbargo");
        DryadDataFile instance = DryadDataFile.create(context);
        instance.clearEmbargo();
        instance.setEmbargo("oneyear", futureDate);
        instance.clearEmbargo();
        assertFalse(instance.isEmbargoed());
    }

    /**
     * Test of setEmbargo method, of class DryadDataFile.
     */
    @Test
    public void testSetEmbargo() throws Exception {
        System.out.println("setEmbargo");
        DryadDataFile instance = DryadDataFile.create(context);
        instance.setEmbargo("untilArticleAppears", futureDate);
        assertTrue(instance.isEmbargoed());
    }
}

@@ -688,47 +688,8 @@
 ate;
-%0A    public DryadDataFileTest() %7B%0A    %7D
 %0A%0A  
@@ -697,21 +697,16 @@
  @Before
-Class
 %0A    pub
@@ -705,31 +705,24 @@
 %0A    public 
-static 
 void setUpCl
@@ -719,21 +719,16 @@
 id setUp
-Class
 () %7B%0A   
@@ -732,112 +732,26 @@
     
-%7D%0A%0A
     
-@AfterClass%0A    public static void tearDownClass() %7B%0A    %7D%0A%0A    @Before%0A    public void 
+super.
 setUp()
- %7B
+;
 %0A   
@@ -1083,55 +1083,8 @@
  %7D%0A%0A
-    @After%0A    public void tearDown() %7B%0A    %7D%0A%0A
     

Fix up DryadDataFile, remove empty overrides