<commit_before>package gov.nih.nci.cabig.caaers.web.admin;

import gov.nih.nci.cabig.caaers.CaaersDbTestCase;
import gov.nih.nci.cabig.caaers.dao.AgentDao;
import gov.nih.nci.cabig.caaers.dao.AgentSpecificTermDao;
import gov.nih.nci.cabig.caaers.dao.StudyAgentDao;
import gov.nih.nci.cabig.caaers.dao.StudyDao;
import gov.nih.nci.cabig.caaers.domain.AgentSpecificTerm;
import gov.nih.nci.cabig.caaers.domain.Study;
import gov.nih.nci.cabig.caaers.domain.repository.TerminologyRepository;
import gov.nih.nci.cabig.caaers.service.AgentSpecificAdverseEventListService;
import org.dbunit.operation.DatabaseOperation;

import java.io.File;
import java.util.List;


/**
 * @author <NAME>
 *
 */
public class AgentSpecificTermsImporterTest extends CaaersDbTestCase {

    private static String fileName = "gov/nih/nci/cabig/caaers/asaelTest.csv";
    private AgentSpecificTermDao agentSpecificTermDao;
    private AgentDao agentDao;
    private TerminologyRepository tRepository;
    private AgentSpecificAdverseEventListService asaelService;
    private StudyDao studyDao;
    private StudyAgentDao studyAgentDao;

	protected void setUp() throws Exception {
        super.setUp();
        agentSpecificTermDao = (AgentSpecificTermDao)getDeployedApplicationContext().getBean("agentSpecificTermDao");
        agentDao = (AgentDao)getDeployedApplicationContext().getBean("agentDao");
        tRepository = (TerminologyRepository)getDeployedApplicationContext().getBean("terminologyRepository");
        agentSpecificTermDao = (AgentSpecificTermDao)getDeployedApplicationContext().getBean("agentSpecificTermDao");
        asaelService = (AgentSpecificAdverseEventListService)getDeployedApplicationContext().getBean("agentSpecificAdverseEventListService");
        studyDao = (StudyDao)getDeployedApplicationContext().getBean("studyDao");
        studyAgentDao = (StudyAgentDao)getDeployedApplicationContext().getBean("studyAgentDao");
	}

    public void testImporter() throws Exception {
        String filePath = AgentSpecificTermsImporterTest.class.getClassLoader().getResource(fileName).getPath();
        AgentSpecificTermsImporter im = new AgentSpecificTermsImporter(new File(filePath));
        im.setAgentDao(agentDao);
        im.setTerminologyRepository(tRepository);
        im.setAgentSpecificTermDao(agentSpecificTermDao);
        im.setAsaelService(asaelService);
        im.setStudyDao(studyDao);
        im.setStudyAgentDao(studyAgentDao);
        im.importFile();
        List<AgentSpecificTerm> l = agentSpecificTermDao.getAll();
        Study s = studyDao.getById(-2);
        assertEquals(1, s.getExpectedAECtcTerms().size());
        assertEquals(4, l.size());
    }

/*
    public void testImporter2() throws Exception {
        String filePath = "d:\\ASAEL.Paul.xls";
        AgentSpecificTermsImporter im = new AgentSpecificTermsImporter(new File(filePath));
        im.importFile();
    }
*/
/*
    @Override
    protected DatabaseOperation getTearDownOperation() throws Exception {
        return DatabaseOperation.REFRESH;
    }


    @Override
    protected DatabaseOperation getSetUpOperation() throws Exception {
        return DatabaseOperation.CLEAN_INSERT;
    }

*/
}<commit_msg>CAAERS-3775 - CALGB: Validation error message shown twice for Missing other meddra in CAE>>Adverse events flow.<commit_after>package gov.nih.nci.cabig.caaers.web.admin;

import gov.nih.nci.cabig.caaers.CaaersDbNoSecurityTestCase;
import gov.nih.nci.cabig.caaers.CaaersDbTestCase;
import gov.nih.nci.cabig.caaers.dao.AgentDao;
import gov.nih.nci.cabig.caaers.dao.AgentSpecificTermDao;
import gov.nih.nci.cabig.caaers.dao.StudyAgentDao;
import gov.nih.nci.cabig.caaers.dao.StudyDao;
import gov.nih.nci.cabig.caaers.domain.AgentSpecificTerm;
import gov.nih.nci.cabig.caaers.domain.Study;
import gov.nih.nci.cabig.caaers.domain.repository.TerminologyRepository;
import gov.nih.nci.cabig.caaers.service.AgentSpecificAdverseEventListService;
import org.dbunit.operation.DatabaseOperation;

import java.io.File;
import java.util.List;


/**
 * @author <NAME>
 *
 */
public class AgentSpecificTermsImporterTest extends CaaersDbNoSecurityTestCase {

    private static String fileName = "gov/nih/nci/cabig/caaers/asaelTest.csv";
    private AgentSpecificTermDao agentSpecificTermDao;
    private AgentDao agentDao;
    private TerminologyRepository tRepository;
    private AgentSpecificAdverseEventListService asaelService;
    private StudyDao studyDao;
    private StudyAgentDao studyAgentDao;

	protected void setUp() throws Exception {
        super.setUp();
        agentSpecificTermDao = (AgentSpecificTermDao)getDeployedApplicationContext().getBean("agentSpecificTermDao");
        agentDao = (AgentDao)getDeployedApplicationContext().getBean("agentDao");
        tRepository = (TerminologyRepository)getDeployedApplicationContext().getBean("terminologyRepository");
        agentSpecificTermDao = (AgentSpecificTermDao)getDeployedApplicationContext().getBean("agentSpecificTermDao");
        asaelService = (AgentSpecificAdverseEventListService)getDeployedApplicationContext().getBean("agentSpecificAdverseEventListService");
        studyDao = (StudyDao)getDeployedApplicationContext().getBean("studyDao");
        studyAgentDao = (StudyAgentDao)getDeployedApplicationContext().getBean("studyAgentDao");
	}

    public void testImporter() throws Exception {
        String filePath = AgentSpecificTermsImporterTest.class.getClassLoader().getResource(fileName).getPath();
        AgentSpecificTermsImporter im = new AgentSpecificTermsImporter(new File(filePath));
        im.setAgentDao(agentDao);
        im.setTerminologyRepository(tRepository);
        im.setAgentSpecificTermDao(agentSpecificTermDao);
        im.setAsaelService(asaelService);
        im.setStudyDao(studyDao);
        im.setStudyAgentDao(studyAgentDao);
        im.importFile();
        List<AgentSpecificTerm> l = agentSpecificTermDao.getAll();
        Study s = studyDao.getById(-2);
        assertEquals(1, s.getExpectedAECtcTerms().size());
        assertEquals(4, l.size());
    }

/*
    public void testImporter2() throws Exception {
        String filePath = "d:\\ASAEL.Paul.xls";
        AgentSpecificTermsImporter im = new AgentSpecificTermsImporter(new File(filePath));
        im.importFile();
    }
*/
/*
    @Override
    protected DatabaseOperation getTearDownOperation() throws Exception {
        return DatabaseOperation.REFRESH;
    }


    @Override
    protected DatabaseOperation getSetUpOperation() throws Exception {
        return DatabaseOperation.CLEAN_INSERT;
    }

*/
}
{'fraction_non_alphanumeric': 0.09948281107392759, 'fraction_numerical': 0.0018253726802555522, 'mean_word_length': 4.619658119658119, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4338347', 'n_tokens_mistral': 2030, 'n_tokens_neox': 2042, 'n_words': 288}