1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.modules.hl7.parser;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
21
22 import java.util.Map;
23
24 import ca.uhn.hl7v2.HL7Exception;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.openehealth.ipf.modules.hl7.config.CustomModelClassFactoryConfigurer;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.test.context.ContextConfiguration;
30 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
31
32 @RunWith(SpringJUnit4ClassRunner.class)
33 @ContextConfiguration(locations = { "/context-custom-configurer.xml",
34 "/context-custom-classes.xml" })
35 public class GroovyCustomModelClassFactoryTest {
36
37 @Autowired
38 private CustomModelClassFactoryConfigurer configurer;
39
40 @Test
41 public void testMappings() throws HL7Exception {
42 Map<String, String[]> map = configurer.getCustomModelClassFactory().getCustomModelClasses();
43 assertTrue(map.containsKey("2.5"));
44 assertTrue(map.containsKey("2.4"));
45 Class<?> clazz = configurer.getCustomModelClassFactory()
46 .getMessageClass("MDM_T01", "2.5", false);
47 assertNotNull(clazz);
48 assertEquals("org.openehealth.ipf.modules.hl7.parser.test.hl7v2.def.v25.message.MDM_T01",
49 clazz.getCanonicalName());
50 Class<?> clazz1 = configurer.getCustomModelClassFactory()
51 .getMessageClass("MDM_T02", "2.4", false);
52 assertNotNull(clazz1);
53 assertEquals("org.openehealth.ipf.modules.hl7.parser.groovytest.hl7v2.def.v24.message.MDM_T02",
54 clazz1.getCanonicalName());
55 }
56 }