package com.hida.dao;

import com.hida.model.Purl;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;
import org.testng.Assert;

/**
 * Tests the functionality of PurlDaoTest and ensures that it properly interacts
 * with Hibernate.
 *
 * @author lruffin
 */
public class PurlDaoImplTest extends EntityDaoImplTest {
    
    @Autowired
    private PurlDao Dao;

    /**
     * Retrieves data from an xml file sheet to mock Pids.
     *
     * @return a data set
     * @throws Exception
     */
    @Override
    protected IDataSet getDataSet() throws Exception {
        IDataSet dataSet = new FlatXmlDataSet(this.getClass().getClassLoader().
                getResourceAsStream("Purl.xml"));
        return dataSet;
    }

    /**
     * Tests to see if a purl entity is retrievable
     */
    @Test
    public void testFindByPurl() {
        Purl entity1 = Dao.findByPurl("abc123");
        Purl entity2 = Dao.findByPurl("xyz");
        Purl entity3 = Dao.findByPurl("null");
        
        Assert.assertNotNull(entity1);
        Assert.assertNotNull(entity2);
        Assert.assertNull(entity3);        
    }

    /**
     * Tests to see if a purl object can be saved
     */
    @Test
    public void testSavePurl() {
        Purl purl = new Purl("pid","url","erc","who","what","date");
        Dao.savePurl(purl);
        
        Purl entity = Dao.findByPurl("pid");
        Assert.assertNotNull(entity);
    }

    @Test
    public void testDeletePurl() {
        Assert.fail("unimplemented");
    }

}

@@ -1554,86 +1554,312 @@
     
-@Test%0A    public void testDeletePurl() %7B%0A        Assert.fail(%22unimplemented%22);
+/**%0A     * Tests to see if a purl entity can be removed%0A     */%0A    @Test%0A    public void testDeletePurl() %7B%0A        Purl entity = Dao.findByPurl(%22abc123%22);%0A        %0A        Dao.deletePurl(entity);%0A        %0A        Purl nullEntity = Dao.findByPurl(%22abc123%22);%0A        Assert.assertNull(nullEntity);       
 %0A   

Complete testDeletePurl