source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Common/NhincLib/test/gov/hhs/fha/nhinc/util/format/DocumentClassCodeParserTest.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 2.6 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package gov.hhs.fha.nhinc.util.format;
6
7import gov.hhs.fha.nhinc.nhinclib.NullChecker;
8import java.util.List;
9import org.junit.AfterClass;
10import org.junit.BeforeClass;
11import org.junit.Test;
12import static org.junit.Assert.*;
13
14/**
15 *
16 * @author rayj
17 */
18public class DocumentClassCodeParserTest {
19
20 public DocumentClassCodeParserTest() {
21 }
22
23 @BeforeClass
24 public static void setUpClass() throws Exception {
25 }
26
27 @AfterClass
28 public static void tearDownClass() throws Exception {
29 }
30
31 @Test
32 public void SingleItemFormattedTest1() {
33 String input = "('1')";
34 int expectedResultSize = 1;
35 String expectedOutputList = "1";
36 PerformTest(input, expectedResultSize, expectedOutputList);
37 }
38
39 @Test
40 public void SingleItemNotFormattedTest() {
41 String input = "1";
42 int expectedResultSize = 1;
43 String expectedOutputList = "1";
44 PerformTest(input, expectedResultSize, expectedOutputList);
45 }
46
47 @Test
48 public void MultipleItemsTest() {
49 String input = "('1,2,3')";
50 int expectedResultSize = 3;
51 String expectedOutputList = "1,2,3";
52 PerformTest(input, expectedResultSize, expectedOutputList);
53 }
54
55 @Test
56 public void MultipleItemsTest2() {
57 String input = "('aa,bb,cc')";
58 int expectedResultSize = 3;
59 String expectedOutputList = "aa,bb,cc";
60 PerformTest(input, expectedResultSize, expectedOutputList);
61 }
62
63 @Test
64 public void NullInput() {
65 String input = null;
66 int expectedResultSize = 0;
67 String expectedOutputList = null;
68 PerformTest(input, expectedResultSize, expectedOutputList);
69 }
70
71 @Test
72 public void EmptyInput() {
73 String input = "";
74 int expectedResultSize = 0;
75 String expectedOutputList = null;
76 PerformTest(input, expectedResultSize, expectedOutputList);
77 }
78
79 private void PerformTest(String input, int expectedResultSize, String expectedResultList) {
80 List<String> result = DocumentClassCodeParser.parseFormattedParameter(input);
81 assertNotNull(result);
82 assertEquals(expectedResultSize, result.size());
83 String resultList = null;
84 for (String item : result) {
85 if (NullChecker.isNotNullish(item)) {
86 if (resultList == null) {
87 resultList = item;
88 } else {
89 resultList = resultList + "," + item;
90 }
91 }
92 }
93
94 assertEquals(expectedResultList, resultList);
95 }
96}
Note: See TracBrowser for help on using the repository browser.