<commit_before>/*******************************************************************************
 * Copyright SemanticBits, Northwestern University and Akaza Research
 * 
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/caaers/LICENSE.txt for details.
 ******************************************************************************/
package gov.nih.nci.cabig.caaers.domain.expeditedfields;

import gov.nih.nci.cabig.caaers.CaaersTestCase;

import java.util.ArrayList;
import java.util.List;

/**
 * This class tests CaaersFieldTree class.
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 */
public class CaaersFieldsTreeTest extends CaaersTestCase {
	private CaaersFieldsTree tree;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        tree = (CaaersFieldsTree)getDeployedApplicationContext().getBean("caaersFieldsTree");
    }

    public void testRecurcivelyCollectListNodes(){
        List<TreeNode> nodes = new ArrayList<TreeNode>();
        tree.recursivelyCollectListNodes(nodes);
        assertEquals("adverseEvents", nodes.get(0).getPropertyName());
    }

    public void testSections() {
        assertEquals(2, tree.getChildren().size());
    }
    
    //checks whether the call is properly getting delegated to expedited tree. 
    public void testInitialize() {
    	ExpeditedReportTree reportTree;
    	try {
    		reportTree = registerMockFor(ExpeditedReportTree.class);
    	} catch (RuntimeException re) {
    		return;
    	}
        tree.setExpeditedReportTree(reportTree);

        reportTree.reinitialize();
        
        replayMocks();
        tree.initialize();
        verifyMocks();
    }

    //checks that if expedited report tree is null, the initialize will not throw NPE.
    public void testInitializeWillNotThrowNPE(){
        try{
            tree.setExpeditedReportTree(null);
            tree.initialize();
        }catch(NullPointerException npe){<commit_msg>undo local change to make unit test pass.<commit_after>/*******************************************************************************
 * Copyright SemanticBits, Northwestern University and Akaza Research
 * 
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/caaers/LICENSE.txt for details.
 ******************************************************************************/
package gov.nih.nci.cabig.caaers.domain.expeditedfields;

import gov.nih.nci.cabig.caaers.CaaersTestCase;

import java.util.ArrayList;
import java.util.List;

/**
 * This class tests CaaersFieldTree class.
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 */
public class CaaersFieldsTreeTest extends CaaersTestCase {
	private CaaersFieldsTree tree;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        tree = (CaaersFieldsTree)getDeployedApplicationContext().getBean("caaersFieldsTree");
    }

    public void testRecurcivelyCollectListNodes(){
        List<TreeNode> nodes = new ArrayList<TreeNode>();
        tree.recursivelyCollectListNodes(nodes);
        assertEquals("adverseEvents", nodes.get(0).getPropertyName());
    }

    public void testSections() {
        assertEquals(2, tree.getChildren().size());
    }
    
    //checks whether the call is properly getting delegated to expedited tree. 
    public void testInitialize(){
        ExpeditedReportTree reportTree = registerMockFor(ExpeditedReportTree.class);
        tree.setExpeditedReportTree(reportTree);

        reportTree.reinitialize();
        
        replayMocks();
        tree.initialize();
        verifyMocks();
    }

    //checks that if expedited report tree is null, the initialize will not throw NPE.
    public void testInitializeWillNotThrowNPE(){
        try{
            tree.setExpeditedReportTree(null);
            tree.initialize();
        }catch(NullPointerException npe){
{'fraction_non_alphanumeric': 0.17165515477104118, 'fraction_numerical': 0.0015349194167306216, 'mean_word_length': 3.6, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3026877', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1026, 'n_words': 240}