View Javadoc
1   package org.kuali.ole.utility.callnumber;
2   
3   import junit.framework.Assert;
4   import org.junit.Test;
5   import org.kuali.ole.docstore.xstream.BaseTestCase;
6   
7   
8   /**
9    * Created with IntelliJ IDEA.
10   * User: ?
11   * Date: 2/14/13
12   * Time: 2:32 PM
13   * To change this template use File | Settings | File Templates.
14   */
15  public class DDCallNumber_UT extends BaseTestCase {
16      @Test
17      public void testNormalize() {
18          try {
19              String callNumberType = "DDC";
20              //String lcCallNumber="3.1 A12b C12 1981";
21              String[] callNumberArrayForDD = {"622.33 B11b C23", "621.06 I59pjm", "621.06 I59pk", "621.06 I59pka", "621.19 G293s5", "621.2 D186iE"};
22              String[] normalizedCallNumberForDD = {"622.33000000 B11 b C000023", "621.06000000 I59 pjm", "621.06000000 I59 pk", "621.06000000 I59 pka", "621.19000000 G293 s000005", "621.20000000 D186 iE"};
23              CallNumber callNumber = CallNumberFactory.getInstance().getCallNumber(callNumberType);
24  
25              for (int i = 0; i < callNumberArrayForDD.length; i++) {
26                  String normalisedCallNumber = callNumber.getSortableKey(callNumberArrayForDD[i]);
27                  System.out.println(callNumberArrayForDD[i] + ":\tnormalized call number:\t" + normalisedCallNumber);
28                  Assert.assertEquals(normalizedCallNumberForDD[i], normalisedCallNumber);
29              }
30          } catch (Exception e) {
31              e.printStackTrace();
32          }
33  
34      }
35  
36      @Test
37      public void testValidCallNumber() throws Exception {
38          String callNumberType = "DDC";
39          //   String number = "1008 .E35 v.1 2006 no.1";
40          String number = "70E35 v.1 2006 no.1";
41          CallNumber callNumber = CallNumberFactory.getInstance().getCallNumber(callNumberType);
42          boolean valid = callNumber.isValid(number);
43          if (valid) {
44              String sortableKey = callNumber.getSortableKey(number);
45              System.out.println("Sortable key:" + sortableKey);
46          }
47          System.out.println("valid:" + valid);
48      }
49  }