View Javadoc
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   import org.solrmarc.callnum.CallNumber;
7   
8   /**
9    * Created with IntelliJ IDEA.
10   * User: ?
11   * Date: 2/15/13
12   * Time: 12:32 PM
13   * To change this template use File | Settings | File Templates.
14   */
15  public class SuDocCallNumber_UT extends BaseTestCase {
16  
17      @Test
18      public void testNormalize() {
19          try {
20              String callNumberType = "SuDoc";
21              //String lcCallNumber="D 5.354:TPC Q-28 D/992";
22  
23              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",
24                      "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",
25                      "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"};
26              String[] normalizedCallNumberForSuDoc = {"C     00003 00186 P     00070 00002", "C     00013 00058 07564", "C     00013 00058 07611", "D     00005 00354 TPC   Q     00028 D     00992",
27                      "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",
28                      "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",
29                      "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"};
30              CallNumber callNumber = CallNumberFactory.getInstance().getCallNumber(callNumberType);
31              for (int i = 0; i < callNumberArrayForSuDoc.length; i++) {
32                  callNumber.parse(callNumberArrayForSuDoc[i]);
33                  String normalisedCallNumber = callNumber.getShelfKey();
34                  System.out.println(callNumberArrayForSuDoc[i] + ":\tnormalized call number:\t" + normalisedCallNumber);
35                  Assert.assertEquals(normalizedCallNumberForSuDoc[i], normalisedCallNumber);
36              }
37          } catch (Exception e) {
38              e.printStackTrace();
39          }
40      }
41  
42  
43      @Test
44      public void testValidCallNumber() throws Exception {
45          String callNumberType = "SuDoc";
46          String number = "DK602 .P44 1901";
47          CallNumber callNumber = CallNumberFactory.getInstance().getCallNumber(callNumberType);
48          callNumber.parse(number);
49          boolean valid = callNumber.isValid();
50          System.out.println("valid:" + valid);
51      }
52  
53  }