package gov.va.med.esr.service;

import gov.va.med.esr.common.model.lookup.RegistryType;
import gov.va.med.esr.common.persistent.registry.RegistryDAO;
import gov.va.med.esr.common.util.RuleAbstractTestCase;

/**
 * 
 * @author Carlos Ruiz
 * @version 1.0
 */
public class RegistryServiceTest extends RuleAbstractTestCase {
    private  RegistryService registryService = null;
    private RegistryDAO registryDAO;    
    
    public RegistryServiceTest(String testName) {
        super(testName);
        // TODO Auto-generated constructor stub
    }

//    public void testSearch() throws Exception {
//        
//        RegistrySearchCriteria criteria = new RegistrySearchCriteria();
//        
//        criteria.setSsn("037223441");
//        criteria.setLastName("PIERCE");
//        criteria.setFirstName("WILLIAM");
//        criteria.setMilitaryServiceNumber("123456789");
//        criteria.setRegistryType(getLookupService().getRegistryTypeByCode(RegistryType.CODE_PH_REGISTRY.getCode()));
//
//        List list = this.getRegistryService().search(criteria);
//        if(list != null) System.out.println("Found = " + list.size());
//    }
    
    public void testGetRegistry() throws Exception {
        
        RegistrySearchCriteria criteria = new RegistrySearchCriteria();
        
        criteria.setSsn("037223441");
        criteria.setLastName("PIERCE");
        criteria.setFirstName("WILLIAM");
        criteria.setMilitaryServiceNumber("123456789");
        criteria.setRegistryType(getLookupService().getRegistryTypeByCode(RegistryType.CODE_PH_REGISTRY.getCode()));

        //Registry registry = this.registryDAO.getRegistry(criteria);
    }
    
//    public void testProcessRegistry() throws Exception {
//        Person onFile = this.buildSimplePerson();
//        SSN ssn = this.createSSN();
//        ssn.setType(this.getLookupService().getSSNTypeByCode(SSNType.CODE_OFFICIAL.getCode()));
//        onFile.addSsn(ssn);
//        Person updated = this.getPersonService().save(onFile);
//        Registry reg = this.createPHRegistry(updated);        
//        registryDAO.save(reg);  // need to wait until person has an id      
//        Person incoming = (Person)updated.clone();
//        PurpleHeart inPH = incoming.getPurpleHeart();
//        inPH.addDocument(this.createPHDocument());
//        LoadRegistryResult lrr = this.getRegistryService().processRegistry((Registry)inPH);
//        PurpleHeart ph = (PurpleHeart)lrr.getResultRegistry();
//       // assertTrue(lrr.isNewRegistry());
//       // assertTrue(ph.getDocuments().size() == 2);        
//    }
//    
//    public void testGetMostRecentRegistrySummaryByType() throws Exception
//    {
//        RegistryLoadStatistics stats = this.getRegistryService().getMostRecentRegistrySummaryByType(
//                getLookupService().getRegistryTypeByCode(
//                        RegistryType.CODE_POW_REGISTRY.getCode()));
//        
//        assertNotNull("RegistryLoadStatistics is null ", stats);
//    }

    /**
     * @return Returns the registryService.
     */
    public RegistryService getRegistryService() {
        return registryService;
    }

    /**
     * @param registryService The registryService to set.
     */
    public void setRegistryService(RegistryService registryService) {
        this.registryService = registryService;
    }

    /**
     * @return Returns the registryDAO.
     */
    public RegistryDAO getRegistryDAO() {
        return registryDAO;
    }

    /**
     * @param registryDAO The registryDAO to set.
     */
    public void setRegistryDAO(RegistryDAO registryDAO) {
        this.registryDAO = registryDAO;
    }
    
    
}
