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);        
    }

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

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

}

@@ -1249,82 +1249,299 @@
     
-@Test%0A    public void testSavePurl() %7B%0A        Assert.fail(%22unimplemented%22
+/**%0A     * Tests to see if a purl object can be saved%0A     */%0A    @Test%0A    public void testSavePurl() %7B%0A        Purl purl = new Purl(%22pid%22,%22url%22,%22erc%22,%22who%22,%22what%22,%22date%22);%0A        Dao.savePurl(purl);%0A        %0A        Purl entity = Dao.findByPurl(%22pid%22);%0A        Assert.assertNotNull(entity
 );%0A 

Complete testSavePurl