/**
 * <!-- LICENSE_TEXT_START -->
 * <!-- LICENSE_TEXT_END -->
 */

package gov.nih.nci.caadapter.hl7.junit;

import gov.nih.nci.caadapter.common.Message;
import gov.nih.nci.caadapter.hl7.transformation.TransformationService;
import gov.nih.nci.caadapter.hl7.transformation.data.XMLElement;

import java.util.List;

import junit.framework.JUnit4TestAdapter;
import junit.framework.TestCase;

import org.junit.Test;

/**
 * The class tests the CSV to HL7v3 transformation service.
 * 
 * @author OWNER: Wang, Eugene
 * @author LAST UPDATE $Author: wangeug $
 * @version Since caAdapter v4.0 revision $Revision: 1.3 $ date $Date: 2007-10-15 20:46:26 $
 */

public class DemoCSV2HL7v3TransformationTests extends TestCase {


	 /**
	  * Test general transformation
	  */
	 @Test public void testTransformation() throws Exception{
	     String csvSrcFile=System.getProperty("hl7.transformation.src.file");
	     String mapFile=System.getProperty("hl7.transformation.map.file");
		 System.out.println("DemoCSV2HL7v3TransformationTests..sourceFie:"+csvSrcFile);
		 System.out.println("DemoCSV2HL7v3TransformationTests..mapFie:"+mapFile);
		 TransformationService ts = new TransformationService(mapFile, csvSrcFile);//
		 List<XMLElement> xmlElements = ts.process();
	     assertEquals(1,xmlElements.size());
	     for(XMLElement rootElement: xmlElements) {
	        	System.out
						.println("CSV2HL7v3TransformationTests.testTransformation()..message\n"+rootElement.toXML());
//	        	rootElement.validate();
//	        	List<Message> vs = rootElement.getValidatorResults().getAllMessages();
//	        	assertEquals(9,vs.size());
//	        	boolean messageFlag = false;
//	        	for(Message message:vs) {
//	        		if (message.toString().equals("H3S Data Object modeCode has 2 attribute(s), but HL7 Attribute Encounter.consultant00.modeCode specifies cardinality 0..1"))
//	        		{
//	        			messageFlag = true;
//	        		}
//	        	}
//	        	assertEquals(true, messageFlag);
	        }
	        
	 }

	 public static junit.framework.Test suite() {
		  return new JUnit4TestAdapter(DemoCSV2HL7v3TransformationTests.class);    
	}
}

@@ -606,17 +606,17 @@
 sion: 1.
-3
+4
  $ date 
@@ -638,15 +638,15 @@
 15 2
-0:46:26
+1:29:21
  $%0A 
@@ -1257,50 +1257,8 @@
 ();%0A
-%09     assertEquals(1,xmlElements.size());%0A
 %09   
@@ -1299,18 +1299,16 @@
 lements)
- %7B
 %0A%09      
@@ -1309,17 +1309,16 @@
         
-%09
 System.o
@@ -1323,15 +1323,8 @@
 .out
-%0A%09%09%09%09%09%09
 .pri
@@ -1417,548 +1417,8 @@
 ));%0A
-//%09        %09rootElement.validate();%0A//%09        %09List%3CMessage%3E vs = rootElement.getValidatorResults().getAllMessages();%0A//%09        %09assertEquals(9,vs.size());%0A//%09        %09boolean messageFlag = false;%0A//%09        %09for(Message message:vs) %7B%0A//%09        %09%09if (message.toString().equals(%22H3S Data Object modeCode has 2 attribute(s), but HL7 Attribute Encounter.consultant00.modeCode specifies cardinality 0..1%22))%0A//%09        %09%09%7B%0A//%09        %09%09%09messageFlag = true;%0A//%09        %09%09%7D%0A//%09        %09%7D%0A//%09        %09assertEquals(true, messageFlag);%0A%09        %7D%0A
 %09   

clean code