1 package org.kuali.ole.utility.callnumber;
2
3 import org.junit.Assert;
4 import org.junit.Test;
5 import org.kuali.ole.docstore.xstream.BaseTestCase;
6
7
8
9
10
11
12
13
14 public class SuDocCallNumber_UT extends BaseTestCase {
15
16 @Test
17 public void testNormalize() {
18 try {
19 String callNumberType = "SuDoc";
20
21
22 String[] callNumberArrayForSuDoc = {"C 3.186:P-70/2/", "C 13.58:7564", "C 13.58:7611", "D 5.354:TPC Q-28 D/992", "D 5.354:TPC R-13 D/984",
23 "HE 20.4002:AD 9/2", "HE 20.4002:AD 9/5", "HE 20.4002:F 94", "L 36.202:F 15/2/980", "L 36.202:F 15/3", "Y 1.1/7:109-118", "Y 1.1/7:109-131", "Y 1.1/7:110-6",
24 "Y 4.EC 7:S.HRG.110-646", "Y 4.EC 7:C 73/10", "Y 3.L 52:1/2/", "I 19.102/5:38117-A 1-SP-500/981/NORTH"};
25 String[] normalizedCallNumberForSuDoc = {"C 00003 00186 P 00070 00002", "C 00013 00058 07564", "C 00013 00058 07611", "D 00005 00354 TPC Q 00028 D 00992",
26 "D 00005 00354 TPC R 00013 D 00984", "HE 00020 04002 AD 00009 00002", "HE 00020 04002 AD 00009 00005", "HE 00020 04002 F 00094",
27 "L 00036 00202 F 00015 00002 00980", "L 00036 00202 F 00015 00003", "Y 00001 00001 00007 00109 00118", "Y 00001 00001 00007 00109 00131", "Y 00001 00001 00007 00110 00006",
28 "Y 00004 EC 00007 S HRG 00110 00646", "Y 00004 EC 00007 C 00073 00010", "Y 00003 L 00052 00001 00002", "I 00019 00102 00005 38117 A 00001 SP 00500 00981 NORTH"};
29 CallNumber callNumber = CallNumberFactory.getInstance().getCallNumber(callNumberType);
30 for (int i = 0; i < callNumberArrayForSuDoc.length; i++) {
31 String normalisedCallNumber = callNumber.getSortableKey(callNumberArrayForSuDoc[i]);
32 System.out.println(callNumberArrayForSuDoc[i] + ":\tnormalized call number:\t" + normalisedCallNumber);
33 Assert.assertEquals(normalizedCallNumberForSuDoc[i], normalisedCallNumber);
34 }
35 } catch (Exception e) {
36 e.printStackTrace();
37 }
38 }
39
40
41 @Test
42 public void testValidCallNumber() throws Exception {
43 String callNumberType = "SuDoc";
44 String number = "DK602 .P44 1901";
45 CallNumber callNumber = CallNumberFactory.getInstance().getCallNumber(callNumberType);
46 boolean valid = callNumber.isValid(number);
47 System.out.println("valid:" + valid);
48 }
49
50 }