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
10
11
12
13
14
15 public class DDCallNumber_UT extends BaseTestCase {
16 @Test
17 public void testNormalize() {
18 try {
19 String callNumberType = "DDC";
20
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
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 }