View Javadoc

1   package org.kuali.student.enrollment.class2.courseoffering.krms.naturallanguage.context;
2   
3   import org.junit.Assert;
4   import org.junit.Before;
5   import org.junit.Test;
6   import org.junit.runner.RunWith;
7   import org.kuali.student.common.test.spring.AbstractServiceTest;
8   import org.kuali.student.r2.core.krms.naturallanguage.TermParameterTypes;
9   import org.springframework.test.context.ContextConfiguration;
10  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
11  
12  import java.util.HashMap;
13  import java.util.Map;
14  
15  @RunWith(SpringJUnit4ClassRunner.class)
16  @ContextConfiguration(locations = {"classpath:nl-test-context.xml"})
17  public class PersonContextImplTest extends AbstractServiceTest {
18  
19      private PersonContextImpl personContext = new PersonContextImpl();
20  
21  	private Map<String, Object> term;
22  	private Map<String, Object> term2;
23  	
24  	private void setupTerm1() {
25          Map<String, Object> parameters = new HashMap<String, Object>();
26          parameters.put(TermParameterTypes.PERSON_KEY.getId(),"231231");
27          term = parameters;
28  	}
29  
30  	private void setupTerm2() {
31          Map<String, Object> parameters = new HashMap<String, Object>();
32          parameters.put(TermParameterTypes.PERSON_KEY.getId(),null);
33  		term2 = parameters;
34  	}
35  
36  	@Before
37  	public void beforeMethod() {
38  		setupTerm1();
39  		setupTerm2();
40  	}
41  
42  	@Test
43      public void testCreateContextMap_Person() {
44  		Map<String, Object> contextMap = personContext.createContextMap(term);
45  		String person = (String) contextMap.get(PersonContextImpl.PERSON_TOKEN);
46  
47  		Assert.assertNotNull(contextMap);
48  		Assert.assertEquals("231231", person);
49  	}
50  	
51  	@Test
52      public void testCreateContextMap_NullTokenValues() {
53          Map<String, Object> contextMap = personContext.createContextMap(term2);
54          String person = (String) contextMap.get(PersonContextImpl.PERSON_TOKEN);
55  
56          Assert.assertNotNull(contextMap);
57          Assert.assertEquals(null, person);
58  
59  	}
60  
61  }