package com.hida.dao;

import com.hida.configuration.RepositoryConfiguration;
import com.hida.model.DefaultSetting;
import com.hida.model.TokenType;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
 * Tests the functionality of DefaultSettingDaoImpl.
 *
 * @author lruffin
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {RepositoryConfiguration.class})
public class DefaultSettingDaoImplTest extends EntityDaoImplTest {
       
    //@Autowired
    private DefaultSettingRepository DefaultSettingRepo;
    
    @Autowired
    public void setDefaultSettingRepository(DefaultSettingRepository DefaultSettingRepo) {
        this.DefaultSettingRepo = DefaultSettingRepo;
    }

    /**
     * Returns a data set that Hibernate assumes to be in persistence.
     *
     * @return
     * @throws Exception
     */
    @Override
    protected IDataSet getDataSet() throws Exception {
        IDataSet dataSet = new FlatXmlDataSet(this.getClass().getClassLoader().
                getResourceAsStream("DefaultSetting.xml"));
        return dataSet;
    }

    /**
     * Tests the functionality of DefaultSettingDao save.
     */
    @Test
    public void saveTest() {
        DefaultSettingRepo.save(getSampleDefaultSetting());
        DefaultSetting entity = DefaultSettingRepo.findCurrentDefaultSetting();
        Assert.assertNotNull(entity);
    }

    /**
     * Tests to see if DefaultSettingDao can find an entity with an id of 1.
     */
    @Test
    public void getDefaultSettingTest() {
        DefaultSetting entity = DefaultSettingRepo.findCurrentDefaultSetting();
        Assert.assertNotNull(entity);
    }

    /**
     * Returns a sample DefaultSetting entity.
     *
     * @return
     */
    private DefaultSetting getSampleDefaultSetting() {
        DefaultSetting setting = new DefaultSetting("",
                "",
                TokenType.DIGIT,
                "d",
                1,
                true,
                true,
                true);

        return setting;
    }
}

@@ -157,76 +157,17 @@
 org.
-db
+j
 unit.
-dataset.IDataSet;%0Aimport org.dbunit.dataset.xml.FlatXmlDataSe
+Tes
 t;%0Ai
@@ -326,24 +326,84 @@
 figuration;%0A
+import org.springframework.test.context.TestPropertySource;%0A
 import org.s
@@ -491,44 +491,8 @@
 ert;
-%0Aimport org.testng.annotations.Test;
 %0A%0A/*
@@ -691,99 +691,123 @@
 s%7D)%0A
-public class DefaultSettingDaoImplTest extends EntityDaoImplTest %7B%0A       %0A    //@Autowired
+@TestPropertySource(locations = %22classpath:testConfig.properties%22)%0Apublic class DefaultSettingDaoImplTest %7B%0A       
 %0A   
@@ -1026,24 +1026,27 @@
 gRepo;%0A    %7D
+   
 %0A%0A    /**%0A  
@@ -1054,431 +1054,76 @@
   * 
-Returns a data set that Hibernate assumes to be in persistence.%0A     *%0A     * @return%0A     * @throws Exception%0A     */%0A    @Override%0A    protected IDataSet getDataSet() throws Exception %7B%0A        IDataSet dataSet = new FlatXmlDataSet(this.getClass().getClassLoader().%0A                getResourceAsStream(%22DefaultSetting.xml%22));%0A        return dataSet;%0A    %7D%0A%0A    /**%0A     * Tests the functionality of DefaultSettingDao save
+Tests to see if DefaultSettingDao can find an entity with an id of 1
 .%0A  
@@ -1158,16 +1158,23 @@
 oid 
-saveTest
+testSaveAndFind
 () %7B
@@ -1200,18 +1200,18 @@
 ting
-Repo.save(
+ sample = 
 getS
@@ -1231,27 +1231,25 @@
 etting()
-);%0A
+;
         
 DefaultS
@@ -1244,269 +1244,82 @@
     
-DefaultSetting entity = DefaultSettingRepo.findCurrentDefaultSetting();%0A        Assert.assertNotNull(entity);%0A    %7D%0A%0A    /**%0A     * Tests to see if DefaultSettingDao can find an entity with an id of 1.
+                %0A        DefaultSettingRepo.save(sample);
 %0A     
-*/%0A
     
-@Test%0A    public void getDefaultSettingTest() %7B
+       
 %0A   
@@ -1394,16 +1394,32 @@
 tting();
+                
 %0A       
@@ -1842,11 +1842,19 @@
 g;%0A    %7D
+        
 %0A%7D%0A

Integrate Springboot into DefaultSettingDaoTest